diff --git a/MyOnline/scripts/runMonTask.sh b/MyOnline/scripts/runMonTask.sh new file mode 120000 index 0000000000000000000000000000000000000000..2a8b186c51f1c498b367f7387cca269e211cf2de --- /dev/null +++ b/MyOnline/scripts/runMonTask.sh @@ -0,0 +1 @@ +../../Online/SmiController/scripts/runTask.sh \ No newline at end of file diff --git a/Online/Dataflow/Dataflow/DiskReader.h b/Online/Dataflow/Dataflow/DiskReader.h index f653ee28ddfc00924782ef16a7deb726cb05a49a..e68b1a511234d198537580848f915d989607189c 100644 --- a/Online/Dataflow/Dataflow/DiskReader.h +++ b/Online/Dataflow/Dataflow/DiskReader.h @@ -109,13 +109,13 @@ namespace Online { typedef std::pair<long, unsigned char*> MemBuffer; //typedef std::map<std::string, RawFile> FileMap; /// Flag indicating that MBM event retrieval is active - bool m_receiveEvts; + bool m_receiveEvts { false }; /// Lock handle - lib_rtl_lock_t m_lock; + lib_rtl_lock_t m_lock { nullptr }; /// Reference to buffer manager producer - MBM::Producer* m_producer; + MBM::Producer* m_producer { nullptr }; /// Decompression buffer - MemBuffer deCompress {0, nullptr}; + MemBuffer deCompress {0, nullptr}; /// Property: Partition name string std::string m_partitionName; @@ -131,6 +131,8 @@ namespace Online { std::string m_filePrefix; /// Property: Path to the file containing broken nodes, where no reading should happen std::string m_brokenHostsFile; + /// Property: Name of the DIM run number service (Ignored if not set) + std::string m_runNumberService; /// Property: List of directories containing data files StringV m_dirList; /// Property: List of runs to be processed (as strings!) @@ -164,42 +166,48 @@ namespace Online { /// Property: Pre-allocation size if multiple events should be declared long m_preAllocSize; /// Property: Artificial delay in micro seconds - int m_muDelay = 0; + int m_muDelay { 0 }; /// Property: Memory map files rather than posix open - int m_mmapFiles = 0; + int m_mmapFiles { 0 }; /// Property: Flag to re-use same input file for debugging - int m_reuse_file = 0; + int m_reuse_file { 0 }; /// Property: Flag to patch ODIN bank and keep the same run-number for N events - int m_patch_odin = 0; + int m_patch_odin { 0 }; /// Monitoring quantity: Number of events queued for processing - int m_eventsIN {0}; + int m_eventsIN { 0 }; /// Monitoring quantity: Number of events which finished processing - int m_eventsOUT {0}; + int m_eventsOUT { 0 }; /// Monitoring quantity: Number of events per current input file - int m_evtCountFile; - /// DIM service ID for publishing currentRun - int m_runSvcID; + int m_evtCountFile { 0 }; /// Monitoring quantity: Currently processed run number - int m_currentRun; + int m_currentRun { 0 }; + + /// DIM service ID for publishing currentRun + int m_runSvcID { 0 }; /// DIM service ID for 'GO' command - int m_goSvcID; + int m_goSvcID { 0 }; /// DIM value of GO service - int m_goValue; + int m_goValue { 0 }; + /// DIM service ID for accessing run number if m_runNumberService is set + int m_runNumberSvcID { 0 }; + /// DIM value of run number service + int m_runNumberValue {-1 }; + /// Property: Flag to indicate if in premature stop/pause the file reminder should be saved. - bool m_saveRest; + bool m_saveRest { true }; /// Flag to indicate if the node is in the broken hosts file and hence disabled - bool m_disabled; + bool m_disabled { false }; /// Flag to indicate if PAUSE incident was received or should be sent. - bool m_goto_paused; + bool m_goto_paused { false }; /// Buffer information blocks to be checked before special transitions are completed - MBM::BufferInfo* m_mbmInfos; + MBM::BufferInfo* m_mbmInfos { nullptr }; /// List of files, where something fishy happened while opening - std::set<std::string> m_badFiles; + std::set<std::string> m_badFiles { }; /// Mutex to protect producer from unsolicited cancel requests - std::mutex m_prodLock; + std::mutex m_prodLock { }; /// String keyed map of buffer information blocks. - std::map<std::string,MBM::BufferInfo*> m_mbmInfo; + std::map<std::string,MBM::BufferInfo*> m_mbmInfo { }; class MBMAllocator : public RawFile::Allocator { public: @@ -218,8 +226,11 @@ namespace Online { /// DIM command service callback static void go_handler(void* tag, void* address, int* size); + /// DIM command service callback + static void run_number_change_handler(void* tag, void* address, int* size); /// DIM service update handler static void run_no_update(void* tag, void** buf, int* size, int* first); + static bool check_consumers_partid(const MBM::BufferInfo& info, int pid); static bool check_consumers(const MBM::BufferInfo& info, int pid, int evtyp); diff --git a/Online/Dataflow/Dataflow/EventServer.h b/Online/Dataflow/Dataflow/EventServer.h index 0ef0cbbb84650b7ac1cc38fe210bd235110b49e3..10b9d628a41ac89bf1edc3fde9fb95e95ee2c253 100755 --- a/Online/Dataflow/Dataflow/EventServer.h +++ b/Online/Dataflow/Dataflow/EventServer.h @@ -28,11 +28,11 @@ #endif // Framework includes -#include "Dataflow/DataflowComponent.h" -#include "MBM/bmdef.h" -#include "MBM/Consumer.h" -#include "MBM/Requirement.h" -#include "RTL/rtl.h" +#include <Dataflow/DataflowComponent.h> +#include <MBM/bmdef.h> +#include <MBM/Consumer.h> +#include <MBM/Requirement.h> +#include <RTL/rtl.h> // C/C++ include files #include <mutex> @@ -178,12 +178,10 @@ namespace Online { // Created : 4/10/2016 // //==================================================================== -#include "Dataflow/Incidents.h" -// #include "Dataflow/EventServer.h" -#include "Dataflow/MBMClient.h" -#include "WT/wt_facilities.h" -#include "RTL/Lock.h" -#include "RTL/bits.h" +#include <Dataflow/Incidents.h> +#include <Dataflow/MBMClient.h> +#include <WT/wt_facilities.h> +#include <RTL/bits.h> using namespace std; using namespace Online; @@ -597,6 +595,6 @@ void EventRequestServer::restartRequests() { } /// Declare factory entries: -#include "Dataflow/Plugins.h" +#include <Dataflow/Plugins.h> DECLARE_DATAFLOW_COMPONENT_NS(Online,EventServer) DECLARE_DATAFLOW_COMPONENT_NS(Online,EventRequestServer) diff --git a/Online/Dataflow/options/StorageReader.opts b/Online/Dataflow/options/StorageReader.opts index abb410b842972efbba88295d11ecda146179a0be..b0a95267d362145bab118587869ed170cabef488 100644 --- a/Online/Dataflow/options/StorageReader.opts +++ b/Online/Dataflow/options/StorageReader.opts @@ -24,7 +24,7 @@ Reader.PauseSleep = 1; Reader.InitialSleep = 1; Reader.MaxPauseWait = 1; Reader.RequireConsumers = 0; -Reader.PackingFactor = 1000; +Reader.PackingFactor = 40; Reader.Buffer = "Events"; Reader.Server = "XXEB09.lbdaq.cern.ch:8000"; // diff --git a/Online/Dataflow/options/StorageReaderNFS.opts b/Online/Dataflow/options/StorageReaderNFS.opts new file mode 100644 index 0000000000000000000000000000000000000000..52c1c53114541a3613df8c0ebf3dbbc0659774eb --- /dev/null +++ b/Online/Dataflow/options/StorageReaderNFS.opts @@ -0,0 +1,40 @@ +#pragma print off +#include "$INFO_OPTIONS" +#include "$FARMCONFIGROOT/options/Logging.opts" +#include "$FARMCONFIGROOT/options/Monitoring.opts" +// +Manager.Services = {"Dataflow_MBMClient/MBM", + "Dataflow_StorageReader/Reader", + "Dataflow_RunableWrapper/Wrap" + }; +// +Manager.Runable = "Wrap"; +Wrap.Callable = "Reader"; +// +Reader.PartitionName = @OnlineEnv.PartitionName; +Reader.RunType = @OnlineEnv.RunType; +Reader.Stream = "HLT1"; +Reader.AllowedRuns = { "*" }; +Reader.DeleteFiles = false; +Reader.SaveRest = false; +Reader.FilePrefix = "/objects/data/${PARTITION}/${RUN1000}"; +Reader.FilePrefix = "/daqarea1/objects/nfs_data/${PARTITION}"; +Reader.FilePrefix = "/daqarea1/objects/nfs_data/LHCb/HLT1"; +Reader.PartitionName = @OnlineEnv.PartitionName; +Reader.PauseSleep = 1; +Reader.InitialSleep = 1; +Reader.MaxPauseWait = 1; +Reader.RequireConsumers = 0; +Reader.PackingFactor = 40; +Reader.Buffer = "Events"; +Reader.Server = "XXEB09.lbdaq.cern.ch:8010"; +Reader.DataType = "nfs"; +Reader.NumBuffers = 2; +Reader.NumThreads = 1; +// +MBM.PartitionBuffers = true; +MBM.PartitionName = @OnlineEnv.PartitionName; +MBM.PartitionID = @OnlineEnv.PartitionID; +MBM.Buffers = { "Events" }; +// +Logger.OutputLevel = @OnlineEnv.OutputLevel; diff --git a/Online/Dataflow/options/StorageWriter.opts b/Online/Dataflow/options/StorageWriter.opts index 412f33da907120d279a72e98efd13c8b48ca4ee6..136ede28444b13a7651e2911f78305f4aff09c13 100644 --- a/Online/Dataflow/options/StorageWriter.opts +++ b/Online/Dataflow/options/StorageWriter.opts @@ -3,6 +3,8 @@ #include "$FARMCONFIGROOT/options/Logging.opts" #include "$FARMCONFIGROOT/options/Monitoring.opts" +Logger.OutputLevel = @OnlineEnv.OutputLevel; +// Manager.Services = {"Dataflow_MBMClient/MBM", "Dataflow_MBMSelector/EventProc", "Dataflow_RunableWrapper/Wrap" @@ -30,7 +32,7 @@ Writer.Stream = "HLT1"; Writer.FileName = "/objects/data/${PARTITION}/${STREAM}/${RUN1000}/${RUN}/Run_${RUN}_${NODE}_${TIME}_${PID}_${SEQ}.mdf"; Writer.Server = "XXEB09.lbdaq.cern.ch:8000"; Writer.BufferSizeMB = 2000; -Writer.MinFileSizeMB = 0; +Writer.MinFileSizeMB = 10; Writer.WriteErrorRetry = 100000; Writer.WriteErrorSleep = 3000; Writer.PollTimeout = 100000; // micro-seconds @@ -40,14 +42,3 @@ Writer.CancelTimeout = 100; // seconds Writer.ForceMDF = true; Writer.OutputType = "NETWORK"; // -Writer.BufferSizeMB = 980; -//Writer.BufferSizeMB = 4500; -Writer.NumBuffers = 3; -Writer.FileName = "/daqarea1/objects/nfs_data/${PARTITION}/${STREAM}/${RUN1000}/${RUN}/Run_${RUN}_${NODE}_${TIME}_${PID}_${SEQ}.mdf"; -Writer.FileName = "file:/daqarea1/objects/nfs_data/${PARTITION}/${STREAM}/${RUN1000}/${RUN}/Run_${RUN}_${NODE}_${TIME}_${PID}_${SEQ}.mdf"; -Writer.OutputType = "NFS"; -Writer.MaxFileSizeMB = 5000; -Writer.HaveFileDB = 2; -// -Logger.OutputLevel = @OnlineEnv.OutputLevel; -// diff --git a/Online/Dataflow/options/StorageWriterNFS.opts b/Online/Dataflow/options/StorageWriterNFS.opts new file mode 100644 index 0000000000000000000000000000000000000000..77408f7be476fbee8c5195bb7ce6959370045fba --- /dev/null +++ b/Online/Dataflow/options/StorageWriterNFS.opts @@ -0,0 +1,44 @@ +#pragma print off +#include "$INFO_OPTIONS" +#include "$FARMCONFIGROOT/options/Logging.opts" +#include "$FARMCONFIGROOT/options/Monitoring.opts" + +Logger.OutputLevel = @OnlineEnv.OutputLevel; +// +Manager.Services = {"Dataflow_MBMClient/MBM", + "Dataflow_MBMSelector/EventProc", + "Dataflow_RunableWrapper/Wrap" + }; +Manager.Algorithms = {"Dataflow_EmptyProcessor/Empty"}; +Manager.Runable = "Wrap"; +Wrap.Callable = "EventProc"; +// +EventProc.REQ1 = "EvType=1;TriggerMask=0xffffffff,0xffffffff,0xffffffff,0xffffffff;VetoMask=0,0,0,0;MaskType=ANY;UserType=USER;Frequency=PERC;Perc=100.0"; +EventProc.REQ2 = "EvType=2;TriggerMask=0xffffffff,0xffffffff,0xffffffff,0xffffffff;VetoMask=0,0,0,0;MaskType=ANY;UserType=USER;Frequency=PERC;Perc=100.0"; +EventProc.Input = "Output"; +// +// +OnlineEnv.PartitionBuffers = true; +MBM.PartitionBuffers = true; +MBM.PartitionName = @OnlineEnv.PartitionName; +MBM.PartitionID = @OnlineEnv.PartitionID; +MBM.Buffers = {"Output"}; +// +// +Manager.Algorithms = {"Dataflow_StorageWriter/Writer"}; +Writer.PartitionName = @OnlineEnv.PartitionName; +Writer.RunType = @OnlineEnv.RunType; +Writer.Stream = "HLT1"; +// +Writer.MinFileSizeMB = 10; +Writer.PollTimeout = 100000; // micro-seconds +Writer.NumThreads = 1; +Writer.CancelTimeout = 100; // seconds +Writer.ForceMDF = true; +Writer.Server = "XXEB09.lbdaq.cern.ch:8010"; +Writer.BufferSizeMB = 980; +Writer.NumBuffers = 3; +Writer.FileName = "file:/daqarea1/objects/nfs_data/${PARTITION}/${STREAM}/${RUN1000}/${RUN}/Run_${RUN}_${NODE}_${TIME}_${PID}_${SEQ}.mdf"; +Writer.OutputType = "NFS"; +Writer.MaxFileSizeMB = 5000; +Writer.HaveFileDB = 2; diff --git a/Online/Dataflow/src/Storage/StorageReader.cpp b/Online/Dataflow/src/Storage/StorageReader.cpp index 584d4dc000e035e07b3b2ec7b551c22cce291a95..b26c9c87cd5ddd923c807d89d0302bc808c9d568 100644 --- a/Online/Dataflow/src/Storage/StorageReader.cpp +++ b/Online/Dataflow/src/Storage/StorageReader.cpp @@ -21,6 +21,9 @@ #include <Dataflow/DiskReader.h> // C/C++ include files +#include <list> +#include <mutex> +#include <thread> /// Online namespace declaration namespace Online { @@ -41,22 +44,77 @@ namespace Online { protected: friend class MBMAllocator; /// Property: Server uri: <host-name>:<port> - std::string m_server; + std::string m_server; + /// Property: Preferred input data type + std::string m_dataType; + /// Property: Minimal file size in MBytes + std::size_t m_minFileSizeMB; + /// Property: Number of parallel event buffers + std::size_t m_num_buffers { 0 }; + /// Property: Number of parallel reader threads + std::size_t m_num_threads { 0 }; /// Property: Debug FDB client - int m_debugClient; + int m_debugClient; + /// Property: Poll timeout to detect transfer buffers [microseconds] + int m_poll_tmo { 200 }; + /// Flag to enable buffer loading in asynchronous mode + int m_loadEnabled { true }; + /// Buffer handling thread + std::vector<std::unique_ptr<std::thread> > m_threads; + /// Mutex to lock the event buffer when filling/saving + std::mutex m_mutex; + + struct Buffer { + /// Pointer to the start of the event buffer + std::vector<uint8_t> data; + /// Associated run number + int32_t runNumber {0}; + /// Default constructor + Buffer() = default; + Buffer(Buffer&& copy) = default; + Buffer(const Buffer& copy) = delete; + Buffer& operator=(Buffer&& copy) = default; + Buffer& operator=(const Buffer& copy) = delete; + }; + + /// Free buffers to be used for reading fresh data + std::list<Buffer> m_free; + /// Filled buffers to be worked down and fed to MBM + std::list<Buffer> m_todo; + + /// Buffer currently in use + Buffer m_current; + + DiskIO m_io {*this}; + + protected: /// Runable implementation : Run the class implementation virtual int i_run() override; /// Patch the string array with allowed runs virtual void checkAllowedRuns() override {} + /// Open file from dedicated HLT1 storage with network transfer + int open_file_net(Buffer& buffer); + /// Default file opening using posix + int open_file_posix(Buffer& buffer); + /// Callback to open new storage file + int i_open_file(Buffer& buffer); + /// Callback to open new storage file + int open_file(Buffer& buffer); + /// Asynchronous load data from file to free buffers + void async_load_buffers(); public: /// Standard algorithm constructor StorageReader(const std::string& nam, Context& ctxt); /// Default destructor virtual ~StorageReader() = default; - /// Callback to open new storage file - int openFile(int& runno, std::vector<unsigned char>& buffer, RawFile& input); + /// IService implementation: start the service + virtual int start() override; + /// IService implementation: stop the service + virtual int stop() override; + /// Cancel I/O operations of the dataflow component + virtual int cancel() override; }; } // End namespace Online #endif // ONLINE_DATAFLOW_STORAGEREADER_H @@ -83,10 +141,20 @@ namespace Online { #include <Dataflow/MBMClient.h> #include <Dataflow/DataflowTask.h> #include <Storage/fdb_client.h> +#include <RTL/strdef.h> + +/// ROOT include files +#include <TFile.h> +#include <TSystem.h> +#include <TUri.h> /// C/C++ include files #include <ctime> +namespace { + static constexpr std::size_t MBYTE = (1024e0*1024e0); +} + using namespace Online; using namespace std; @@ -98,45 +166,235 @@ StorageReader::StorageReader(const string& nam, Context& ctxt) : DiskReader(nam, ctxt) { this->declareProperty("Server", this->m_server); - this->declareProperty("DebugClient", this->m_debugClient = 0); + this->declareProperty("DebugClient", this->m_debugClient = 0); + this->declareProperty("DataType", this->m_dataType = "network"); + this->declareProperty("MinFileSizeMB", this->m_minFileSizeMB = 5); + this->declareProperty("NumBuffers", this->m_num_buffers = 0); + this->declareProperty("NumThreads", this->m_num_threads = 0); +} + +/// IService implementation: start the service +int StorageReader::start() { + if ( this->DiskReader::start() != DF_SUCCESS ) + return error("Failed to start service base class."); + this->m_todo.clear(); + this->m_loadEnabled = true; + if ( m_num_buffers > 0 ) { + for(size_t i = 0; i < m_num_buffers; ++i) + m_free.emplace_back(Buffer()); + for(size_t i = 0; i < m_num_threads; ++i) + m_threads.emplace_back(make_unique<thread>([this]() { this->async_load_buffers(); })); + } + return DF_SUCCESS; +} + +/// IService implementation: stop the service +int StorageReader::stop() { + while ( !this->m_todo.empty() ) { + } + for(auto& t : this->m_threads) { + t->join(); + t.reset(); + } + this->m_threads.clear(); + this->m_free.clear(); + return DiskReader::stop(); +} + +/// Cancel I/O operations of the dataflow component +int StorageReader::cancel() { + this->m_loadEnabled = false; + return this->DiskReader::cancel(); } -int StorageReader::openFile(int& runno, std::vector<unsigned char>& buffer, RawFile& input) { +int StorageReader::open_file_net(Buffer& buffer) { using namespace storage; - char text[132]; - time_t date = 0; - size_t length = 0; fdb_client client; uri_t url(this->m_server); - runno = -1; - input.reset(); - buffer.clear(); client.fdbclient = client::create<client::sync>(url.host, url.port, 10000, m_debugClient); client.create_client = std::function(client::create<client::sync>); for(const auto& run : this->m_allowedRuns ) { + time_t date = 0; + size_t length = 0; string file_name = interprete_file_name(m_filePrefix, run); info("Checking for files matching pattern: '%s'", file_name.c_str()); auto reply = client.next_object_delete(file_name, date, length); if ( reply.status == reply.ok ) { - struct tm tim; - ::localtime_r(&date, &tim); - runno = ::strtol(run.c_str(), 0, 10); - buffer = move(reply.content); - input.map_memory(&buffer.at(0), buffer.size()); - ::strftime(text,sizeof(text), "%Y-%m-%d %H:%M:%S", &tim); - info("Opened file: %s [written: %s - %ld bytes]", file_name.c_str(), text, length); + if ( length < m_minFileSizeMB*MBYTE ) { + info("Drop file: %s %ld MB [too-small]", file_name.c_str(), length/MBYTE); + } + buffer.data = move(reply.content); + buffer.runNumber = ::strtol(run.c_str(), 0, 10); + info("Opened file: %s [%ld MB]", file_name.c_str(), length/MBYTE); return DF_SUCCESS; } } + buffer.runNumber = -1; + return DF_ERROR; +} + +int StorageReader::open_file_posix(Buffer& buffer) { + using namespace storage; + unique_ptr<client> client; + uri_t url(this->m_server); + string location; + + buffer.runNumber = -1; + client = client::create<client::sync>(url.host, url.port, 10000, m_debugClient); + for(const auto& run : this->m_allowedRuns ) { + storage::client::reqheaders_t hdrs; + string loc, file_name = interprete_file_name(m_filePrefix, run); + info("Checking for files matching pattern: '%s'", file_name.c_str()); + loc = "/next?prefix="+file_name; + hdrs.emplace_back(http::constants::location, file_name); + reply_t reply = client->request(http::constants::del, loc, hdrs); + if( reply.status == reply.ok || reply.status == reply_t::temp_redirect ) { + for ( const auto& h : reply.headers ) { + if ( h.name == http::constants::location ) { + TUrl url(h.value.c_str()); + TString prot = url.GetProtocol(); + /// If there is a data protocol present, we invoke + /// ROOT to open and read the file as a whole. + TString spec; + TString opts = "filetype=raw"; + TString temp = url.GetOptions(); + if ( temp.Length() > 0 ) { + opts += "&"; + opts += url.GetOptions(); + } + url.SetOptions(opts); + if ( 0 == prot.Length() || prot == "file" || prot == "http" ) { + spec = h.value.c_str(); + spec += "?filetype=raw"; + } + else { + spec = url.GetUrl(); + } + std::unique_ptr<TFile> file(TFile::Open(spec, "READ")); + if ( file.get() && !file->IsZombie() ) { + Long64_t max_chunk = 512*MBYTE; + Long64_t file_length = file->GetSize(); + Long64_t offset = 0; + buffer.data.resize(file_length); + while(offset < file_length) { + Long64_t chunk = (file_length-offset >= max_chunk) ? max_chunk : file_length-offset; + if ( file->ReadBuffer((char*)&buffer.data.at(offset), chunk) == 0 ) { + offset += chunk; + if ( offset >= file_length ) { + info("Opened file: %s [%ld bytes]", spec.Data(), buffer.data.size()); + if ( run == "*" ) { + loc = file->GetName(); + size_t idx = loc.rfind('/')+1; + const char* ptr = loc.c_str() + ((idx != string::npos) ? idx : 0); + if ( 1 != ::sscanf(ptr, "%07d", &buffer.runNumber) ) { + ::sscanf(ptr, "%010d", &buffer.runNumber); + } + } + else { + buffer.runNumber = ::strtol(run.c_str(), 0, 10); + } + return DF_SUCCESS; + } + continue; + } + break; + } + return error("Failed to read data from file: %s", file->GetName()); + } + return error("Failed to open file for match: %s [Protocol error]", location.c_str()); + } + } + } + } + /// Error no location header! + return error("Failed to open new data file."); +} + +int StorageReader::i_open_file(Buffer& buffer) { + string typ = RTL::str_lower(this->m_dataType); + if ( typ == "network" ) { + return this->open_file_net(buffer); + } + else if ( typ == "nfs" || typ == "posix" ) { + return this->open_file_posix(buffer); + } + return error("Failed to open next input file with type: %s.", typ.c_str()); +} + +void StorageReader::async_load_buffers() { + while( this->m_loadEnabled ) { + bool got_buffer = false; + Buffer buffer; + { + lock_guard<mutex> lock(this->m_mutex); + if ( !this->m_free.empty() ) { + buffer = move(this->m_free.front()); + this->m_free.pop_front(); + got_buffer = true; + } + } + + if ( !got_buffer ) { + if ( !this->m_receiveEvts ) + return; + else if ( this->m_goto_paused ) + return; + ::lib_rtl_sleep(m_poll_tmo); + continue; + } + else if ( !this->m_receiveEvts ) { + lock_guard<mutex> lock(this->m_mutex); + this->m_free.emplace_back(move(buffer)); + return; + } + else if ( this->m_goto_paused ) { + lock_guard<mutex> lock(this->m_mutex); + this->m_free.emplace_back(move(buffer)); + return; + } + if ( this->i_open_file(buffer) == DF_SUCCESS ) { + lock_guard<mutex> lock(this->m_mutex); + this->m_todo.emplace_back(move(buffer)); + } + ::lib_rtl_sleep(m_poll_tmo); + } +} + +int StorageReader::open_file(Buffer& buffer) { + // No threading: synchronous reading + if ( this->m_num_buffers == 0 || this->m_num_threads == 0 ) { + int ret = i_open_file(buffer); + return ret; + } + + // Asynchronous reading: Wait until some buffer is ready + { + lock_guard<mutex> lock(this->m_mutex); + if ( !buffer.data.empty() ) { + this->m_free.emplace_back(move(buffer)); + } + } + while( this->m_receiveEvts ) {{ + lock_guard<mutex> lock(this->m_mutex); + if ( !m_todo.empty() ) { + buffer = move(this->m_todo.front()); + this->m_todo.pop_front(); + return DF_SUCCESS; + } + } + if ( this->m_receiveEvts ) { + ::lib_rtl_sleep(m_poll_tmo); + } + } return DF_ERROR; } /// IRunable implementation : Run the class implementation int StorageReader::i_run() { int status; + Buffer current_buffer; // Never clear in here. We try to re-use the memory! RawFile current_input; - vector<unsigned char> event_data; auto* mbmInfo = m_mbmInfo[m_buffer]; this->m_eventsIN = 0; @@ -160,11 +418,11 @@ int StorageReader::i_run() { if ( this->m_muDelay > 0 ) { ::usleep(this->m_muDelay); } - if ( 0 == current_input.data_size() ) { + if ( !(current_input.isMapped() || current_input.isOpen()) ) { int runno = 0; this->updateRunNumber(runno); - status = this->openFile(runno, event_data, current_input); - if ( status == DF_ERROR && m_goto_paused ) { + status = this->open_file(current_buffer); + if ( status == DF_ERROR && this->m_goto_paused ) { // Sleep a bit before goung to pause this->info("Sleeping before going to PAUSE...."); ::lib_rtl_sleep(1000*m_pauseSleep); @@ -181,13 +439,12 @@ int StorageReader::i_run() { ::lib_rtl_lock(m_lock); break; } - this->updateRunNumber(runno); - } - if ( 0 == current_input.data_size() ) { - current_input.reset(); - continue; + current_input.map_memory(¤t_buffer.data.at(0), current_buffer.data.size()); + info("Opened file [%ld bytes]", this->m_current.data.size()); + this->updateRunNumber(current_buffer.runNumber); } - if ( current_input.isMapped() ) { + + if ( current_input.isMapped() || current_input.isOpen() ) { status = this->handle_mbm_request(mbmInfo, current_input); switch(status) { case DF_SUCCESS: @@ -196,6 +453,8 @@ int StorageReader::i_run() { continue; case DF_ERROR: this->m_receiveEvts = false; + this->updateRunNumber(0); + current_input.reset(true); /// Go to state ERROR, all the work is done this->fireIncident("DAQ_ERROR"); return DF_ERROR; @@ -205,7 +464,6 @@ int StorageReader::i_run() { current_input.reset(true); // Bad file: Cannot read input (m_eventsIN==0) this->updateRunNumber(0); - } /// Before actually declaring PAUSED, we wait until no events are pending anymore. this->waitForPendingEvents(this->m_maxPauseWait); diff --git a/Online/Dataflow/src/Storage/StorageWriter.cpp b/Online/Dataflow/src/Storage/StorageWriter.cpp index 133d8c5442c41df877a8548780418b6c17f98640..cfe5ef4636227d89ed0f3ed07d9b1052c04876a6 100644 --- a/Online/Dataflow/src/Storage/StorageWriter.cpp +++ b/Online/Dataflow/src/Storage/StorageWriter.cpp @@ -26,6 +26,11 @@ #include <RTL/strdef.h> #include <RTL/rtl.h> +/// ROOT include files +#include <TFile.h> +#include <TSystem.h> +#include <TUrl.h> + /// C/C++ include files #include <filesystem> #include <sys/types.h> @@ -38,7 +43,7 @@ #include <ctime> namespace { - static constexpr std::size_t MBYTE = (1024e0*1024e0); + static constexpr long MBYTE = (1024e0*1024e0); } using namespace std; @@ -163,7 +168,6 @@ int StorageWriter::finalize() { for(Buffer& b : m_free) ::free(b.buffer); m_free.clear(); - m_client.fdbclient.reset(); int sc = Component::finalize(); return sc; } @@ -391,6 +395,41 @@ int StorageWriter::execute(const Context::EventData& event) { template <typename OUT_TYPE> int StorageWriter::process_posix_buffers() { OUT_TYPE output; + auto add_db_entry = [this] (size_t len, const std::string& fname) { + if ( this->m_haveFileDB ) { + http::HttpReply reply; + try { + string url; + client_t cl; + storage::uri_t srv(this->m_server); + storage::client::reqheaders_t hdrs; + cl.fdbclient = + storage::client::create<storage::client::sync>(srv.host, srv.port, 10000, this->m_debugClient); + if ( this->m_haveFileDB == 2 ) { + hdrs.emplace_back(http::constants::location, fname); + } + reply = cl.save_object_record(fname, url, len, hdrs); + if ( reply.status == reply.temp_redirect ) { + /// OK. the registration was now successful + return true; + } + else { + this->error("posix_buffers: FAILED accessing FDB server: %s", + http::HttpReply::stock_status(reply.status).c_str()); + return false; + } + } + catch(const std::exception& e) { + this->error("posix_buffers: Exception accessing FDB server: %s", e.what()); + return false; + } + catch(...) { + this->error("posix: UNKNOWN Exception accessing FDB server"); + return false; + } + } + return true; + }; while( 1 ) { Buffer b {nullptr, nullptr}; { lock_guard<mutex> bufferLock(m_mutex); @@ -398,60 +437,43 @@ int StorageWriter::process_posix_buffers() { info("process: Exit condition detected. Leaving submit thread."); return DF_SUCCESS; } - else if ( !m_todo.empty() ) { + else if ( m_todo.empty() ) { + if ( m_poll_tmo > 0 ) { + ::lib_rtl_usleep(m_poll_tmo); + } + continue; + } + else { b = m_todo.back(); m_todo.pop_back(); } } if ( b.buffer ) { - std::size_t len = b.pointer - b.buffer; + long len = b.pointer - b.buffer; if ( output.isOpen() ) { if ( output.length + len > m_maxFileSizeMB * MBYTE ) { - warning("Closed output %s after %ld bytes [size-limit].", output.name(), output.length); + warning("Closed output %s after %ld MB [size-limit].", output.name(), output.length/MBYTE); + if ( !add_db_entry(output.length, output.name()) ) { + ::lib_rtl_usleep(m_poll_tmo); + continue; + } output.close(); } else if ( output.run != b.runNumber ) { - warning("Closed output %s after %ld bytes [run-change].", output.name(), output.length); + warning("Closed output %s after %ld MB [run-change].", output.name(), output.length/MBYTE); + if ( !add_db_entry(output.length, output.name()) ) { + ::lib_rtl_usleep(m_poll_tmo); + continue; + } + output.close(); + } + else if ( len < m_minFileSizeMB*MBYTE ) { + warning("Drop output %s after %ld MB [min-file-size].", output.name(), output.length/MBYTE); output.close(); } } if ( !output.isOpen() ) { string fname = makeFileName(b.runNumber); - if ( m_haveFileDB ) { - http::HttpReply reply; - try { - string url; - client_t cl; - storage::uri_t srv(m_server); - storage::client::reqheaders_t hdrs; - cl.fdbclient = - storage::client::create<storage::client::sync>(srv.host, srv.port, 10000, m_debugClient); - if ( m_haveFileDB == 2 ) { - hdrs.emplace_back(http::constants::location, fname); - } - reply = cl.save_object_record(fname, url, len, hdrs); - if ( reply.status == reply.temp_redirect ) { - /// OK. the registration was now successful - fname = url; - } - else { - error("posix_buffers: FAILED accessing FDB server: %s", - http::HttpReply::stock_status(reply.status).c_str()); - ::lib_rtl_usleep(m_poll_tmo); - continue; - } - } - catch(const std::exception& e) { - error("posix_buffers: Exception accessing FDB server: %s", e.what()); - ::lib_rtl_usleep(m_poll_tmo); - continue; - } - catch(...) { - error("posix: UNKNOWN Exception accessing FDB server"); - ::lib_rtl_usleep(m_poll_tmo); - continue; - } - } if ( output.open(fname) <= 0 ) { error("Failed to open output %s. [%s]", fname.c_str(), RTL::errorString(errno).c_str()); this->fireIncident("DAQ_ERROR"); @@ -466,6 +488,10 @@ int StorageWriter::process_posix_buffers() { } else { error("Failed to write buffer to file %s [%s]", output.name(), RTL::errorString(errno).c_str()); + if ( !add_db_entry(output.length, output.name()) ) { + ::lib_rtl_usleep(m_poll_tmo); + //continue; + } output.close(); } { @@ -475,9 +501,10 @@ int StorageWriter::process_posix_buffers() { } continue; } - if ( m_poll_tmo > 0 ) { - ::lib_rtl_usleep(m_poll_tmo); - } + } + if ( output.isOpen() ) { + add_db_entry(output.length, output.name()); + output.close(); } return DF_SUCCESS; } @@ -485,7 +512,7 @@ int StorageWriter::process_posix_buffers() { namespace { struct _OUT { RawFile file; - std::size_t length = 0; + long length = 0; uint32_t run = 0; _OUT() = default; void close() { @@ -514,15 +541,11 @@ namespace { return file.write(b, l); } }; -} -#include <TFile.h> -#include "TSystem.h" -#include "TUrl.h" -namespace { - /// To be done: ROOT implementation + + /// ROOT implementation struct _ROOT { unique_ptr<TFile> file; - std::size_t length = 0; + long length = 0; uint32_t run = 0; _ROOT() = default; ~_ROOT() = default; @@ -579,20 +602,6 @@ namespace { }; } -/// Thread invocation routine to save assembled buffers to the disk server -int StorageWriter::process_buffers() { - switch(m_output_type) { - case NETWORK_STORAGE: - return process_network_buffers(); - case ROOT_STORAGE: - return process_posix_buffers<_ROOT>(); - case POSIX_STORAGE: - return process_posix_buffers<_OUT>(); - default: - return process_posix_buffers<_OUT>(); - } -} - /// Thread invocation routine to save assembled buffers to the disk server int StorageWriter::process_network_buffers() { while( 1 ) { @@ -608,7 +617,7 @@ int StorageWriter::process_network_buffers() { } } if ( b.buffer ) { - size_t len = b.pointer - b.buffer; + long len = b.pointer - b.buffer; /// Skip files with less than a minimum bytes if ( len > m_minFileSizeMB*MBYTE ) { if ( writeBuffer(b) != DF_SUCCESS ) { @@ -632,6 +641,20 @@ int StorageWriter::process_network_buffers() { return DF_SUCCESS; } +/// Thread invocation routine to save assembled buffers to the disk server +int StorageWriter::process_buffers() { + switch(m_output_type) { + case NETWORK_STORAGE: + return process_network_buffers(); + case ROOT_STORAGE: + return process_posix_buffers<_ROOT>(); + case POSIX_STORAGE: + return process_posix_buffers<_OUT>(); + default: + return process_posix_buffers<_OUT>(); + } +} + /// Print server's HttpReply structure void StorageWriter::print_reply(const char* prefix, const http::HttpReply& reply) const { string line; diff --git a/Online/Dataflow/src/Storage/StorageWriter.h b/Online/Dataflow/src/Storage/StorageWriter.h index 12180648b903a7067fec7ba3849b34eef2de6e54..992cb5287a6b232713d540905cb117873c5735bb 100644 --- a/Online/Dataflow/src/Storage/StorageWriter.h +++ b/Online/Dataflow/src/Storage/StorageWriter.h @@ -77,9 +77,9 @@ namespace Online { /// Property: Number of event sender threads std::size_t m_num_threads; /// Property: Minimal file size in MBytes - std::size_t m_minFileSizeMB; + long m_minFileSizeMB; /// Property: Maximal file size in MBytes (used if writing to posix file system) - std::size_t m_maxFileSizeMB; + long m_maxFileSizeMB; /// Property: Sleep in milliseconds between retries when write connection fails int m_write_error_sleep; /// Property: Number of retries when write connection fails @@ -99,11 +99,13 @@ namespace Online { std::vector<thread_t> m_threads; /// Mutex to lock the event buffer when filling/saving std::mutex m_mutex; - /// FDB client object to store event buffers - client_t m_client; + /// Free buffers to be filled when writing std::vector<Buffer> m_free; + /// List of filled buffers to be dumped to storage device std::vector<Buffer> m_todo; + + /// Buffer currently in use Buffer m_current; std::size_t m_sequenceNumber {0}; diff --git a/Online/Dataflow/src/Utils/tell1_check_file.cpp b/Online/Dataflow/src/Utils/tell1_check_file.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0cb5090b52e8f1eeeec4e731b617efff6e7fc30c --- /dev/null +++ b/Online/Dataflow/src/Utils/tell1_check_file.cpp @@ -0,0 +1,251 @@ +//========================================================================== +// LHCb Online software suite +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see OnlineSys/LICENSE. +// +//-------------------------------------------------------------------------- +// +// Package : Dataflow +// +// Author : Markus Frank +//========================================================================== + +// Framework include files +#include <Tell1Data/RawFile.h> +#include <Tell1Data/Tell1Decoder.h> +#include <RZip.h> + +// C/C++ include files +#include <stdexcept> +#include <iostream> +#include <iomanip> +#include <cstdlib> +#include <cstring> +#include <cstdio> +#include <vector> +#include <set> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#include <dirent.h> + +using namespace std; +using namespace Online; + +namespace { + static constexpr int peek_size = int(8*sizeof(int)); + + typedef pair<long, unsigned char*> MemBuffer; + + const char* get_arg(const char* arg) { + const char* p = ::strchr(arg,'='); + if ( p ) return p+1; + throw runtime_error(string("Invalid argument: ")+arg); + } + + long load_mdf_event(RawFile& file, + pair<long,unsigned char*> output, + pair<long,unsigned char*>& decomp ) + { + auto* mdf_hdr = (EventHeader*)output.second; + long status = 0; + int compress = mdf_hdr->compression(); + long data_size = mdf_hdr->recordSize(); + if ( compress > 0 ) { + int new_size = 0; + int tgt_size = 0; + int src_size = data_size; + long hdr_len = mdf_hdr->sizeOf(mdf_hdr->headerVersion()); + + if ( decomp.first < data_size ) { + decomp.first = data_size*1.2; + if ( decomp.second ) delete [] decomp.second; + decomp.second = new unsigned char[decomp.first]; + } + ::memcpy(decomp.second, output.second, peek_size); + status = file.read(decomp.second + peek_size, data_size - peek_size); + if ( status < data_size - peek_size ) { + return -1; + } + if ( hdr_len-peek_size > 0 ) { + ::memcpy(output.second, decomp.second, hdr_len); + } + if ( 0 == ::R__unzip_header(&src_size, decomp.second + hdr_len, &tgt_size) ) { + if ( output.first < (long)tgt_size ) { + return 0; + } + ::R__unzip( &src_size, decomp.second + hdr_len, + &tgt_size, output.second + hdr_len, + &new_size); + if ( new_size > 0 ) { + EventHeader* hdr = (EventHeader*)output.second; + hdr->setHeaderVersion( 3 ); + hdr->setDataType(EventHeader::BODY_TYPE_BANKS); + hdr->setSubheaderLength(sizeof(EventHeader::Header1)); + hdr->setSize(new_size); + hdr->setCompression(0); + hdr->setChecksum(0); + hdr->setSpare(0); + return hdr_len + new_size; + } + } + return -1; + } + if ( output.first < data_size ) { + return 0; + } + status = file.read(output.second + peek_size, data_size - peek_size); + if ( status < data_size - peek_size ) { + return -1; + } + return data_size; + } + + void _read_dir(vector<string>& inputs, const char* fn) { + struct stat stat; + if ( 0 == ::stat(fn, &stat) ) { + switch (stat.st_mode & S_IFMT) { + case S_IFDIR: { + cout << "+++ Use directory content: " << fn << endl; + auto* dir = ::opendir(fn); + dirent* dent; + while((dent=readdir(dir))!=NULL) { + if ( strcmp(dent->d_name,".") == 0 ) continue; + if ( strcmp(dent->d_name,"..") == 0 ) continue; + string f = fn; + f += "/"; + f += dent->d_name; + _read_dir(inputs, f.c_str()); + } + ::closedir(dir); + break; + } + default: + cout << "+++ Use input file: " << fn << endl; + inputs.push_back(fn); + break; + } + } + } +} + +extern "C" int tell1_check_file(int argc, char* argv[]) { + class help { + public: + static void show() { + cout << + "Usage: tell1_check_file -option [-option] \n" + " --input=<file> input file name (multiple entries allowed) \n" + " -i <file> dto. If a directory is given all files are scanned \n" + << endl; + } + }; + vector<string> inputs; + try { + for(int i = 1; i < argc && argv[i]; ++i) { + if ( 0 == ::strncasecmp("--input",argv[i],4) ) { + inputs.push_back(get_arg(argv[i])); + } + else if ( 0 == ::strcasecmp("-i",argv[i]) ) { + inputs.push_back(argv[++i]); + } + else { + throw runtime_error(string("Invalid argument: ")+argv[i]); + } + } + } + catch(const exception& e) { + cout << "Exception: " << e.what() << endl << endl; + help::show(); + return EINVAL; + } + if ( inputs.empty() ) { + cout << "No input files given!" << endl << endl; + help::show(); + return ENOENT; + } + auto files = inputs; + inputs.clear(); + for(size_t i=0; i< files.size(); ++i) + _read_dir(inputs, files[i].c_str()); + + size_t num_evt_total = 0; + size_t num_bytes_total = 0; + clock_t start, end; + + start = clock(); + for(size_t i=0; i< inputs.size(); ++i) { + Online::RawFile input(inputs[i]); + if ( input.open() < 0 ) { + cout << "FAILED to open file: " << inputs[i] << endl; + continue; + } + cout << "+++ Opened file " << inputs[i] << endl; + cout << "+++ File size on disk " << input.data_size() << " bytes " << endl; + + long num_evt_file = 0; + long num_bytes_file = 0; + MemBuffer deCompress; + while(1) { + int size[peek_size/sizeof(int)]; + uint8_t *data_ptr, *alloc_ptr; + off_t position = input.position(); + int status = input.read(size, peek_size); + + auto* mdf_hdr = (EventHeader*)size; + if ( status < int(peek_size) ) { + goto Done; + } + if ( mdf_hdr->is_mdf() ) { + int compress = mdf_hdr->compression(); + long hdr_len = mdf_hdr->sizeOf(mdf_hdr->headerVersion()); + long alloc_size = mdf_hdr->recordSize(); + ++num_evt_file; + ++num_evt_total; + if ( compress > 0 ) { + alloc_size = hdr_len + (mdf_hdr->compression() + 1) * mdf_hdr->size(); + } + alloc_ptr = data_ptr = new uint8_t[alloc_size]; + ::memcpy(data_ptr, size, peek_size); + long length = load_mdf_event(input, MemBuffer(alloc_size,data_ptr), deCompress); + if ( length <= 0 ) { + ::free(alloc_ptr); + goto Done; + } + num_bytes_file += alloc_size; + num_bytes_total += alloc_size; + try { + auto* hdr = (EventHeader*)data_ptr; + /// Check raw bank record + checkRawBanks(hdr->data(), hdr->end(), true, true); + } + catch(const exception& e) { + cout << "+++ MDF Exception: " << e.what() << endl; + cout << " File position:" << position << endl; + } + catch(...) { + cout << "+++ UNKNOWN MDF Exception " << endl; + cout << " File position:" << position << endl; + } + delete [] alloc_ptr; + } + else { + cout << "+++ INVALID MDF Header! " << inputs[i] << ". Read a total of " << num_bytes_file << " bytes" << endl; + cout << " File position:" << position << endl; + break; + } + continue; + + Done: + cout << "+++ End of file. Read " << num_bytes_file << " bytes with a total of " << num_evt_file << " events" << endl; + break; + } + } + end = clock(); + cout << "+++ " << num_evt_total << " Events Processed with " << num_bytes_total << " bytes " + << "Time (ticks): " << long(end-start) << " (total) " << long(end-start)/num_evt_total << " (ticks/event)" << endl; + return 0; +} diff --git a/Online/Dataflow/src/components/BurstReader.cpp b/Online/Dataflow/src/components/BurstReader.cpp index 1ac7c1ee8a677339da6a14bfa503664a942b833c..cdece1f05cf9aef67d01b41188ae68d8b32f5000 100644 --- a/Online/Dataflow/src/components/BurstReader.cpp +++ b/Online/Dataflow/src/components/BurstReader.cpp @@ -20,7 +20,6 @@ #include <Dataflow/Plugins.h> using namespace Online; -using namespace std; // Instantiation of a static factory class used by clients to create instances of this service DECLARE_DATAFLOW_NAMED_COMPONENT_NS(Online,Dataflow_BurstReader,DiskReader) diff --git a/Online/Dataflow/src/components/MBMSelector.cpp b/Online/Dataflow/src/components/MBMSelector.cpp index 10ace352e124ac258272729bd21e5c750de14a54..6927fba11b0d1fcd8635d3fd655ca1565ba5f89d 100755 --- a/Online/Dataflow/src/components/MBMSelector.cpp +++ b/Online/Dataflow/src/components/MBMSelector.cpp @@ -90,7 +90,6 @@ namespace Online { #include <Dataflow/Incidents.h> #include <Dataflow/Plugins.h> #include <MBM/Consumer.h> -#include <RTL/Lock.h> #include <RTL/rtl.h> // C/C++ include files diff --git a/Online/Dataflow/src/components/MEPSelector.cpp b/Online/Dataflow/src/components/MEPSelector.cpp index 1a1aed74d07a533e38e2d9e4375725bf844bcab1..11772b9d4695a13e64f053aea9721e8bfc7c04c0 100755 --- a/Online/Dataflow/src/components/MEPSelector.cpp +++ b/Online/Dataflow/src/components/MEPSelector.cpp @@ -115,7 +115,6 @@ namespace Online { #include <Dataflow/Plugins.h> #include <MBM/Consumer.h> #include <MBM/mepdef.h> -#include <RTL/Lock.h> #include <RTL/rtl.h> #include <NET/IPHeader.h> #include <arpa/inet.h> diff --git a/Online/Dataflow/src/components/UpgradeMEPSelector.cpp b/Online/Dataflow/src/components/UpgradeMEPSelector.cpp index 2f0c544f1f863b7b3c19974064d6b07b58d7f1a5..2aa3d5bb03b2e54ddce0958dabcc2a179e4ef3f1 100644 --- a/Online/Dataflow/src/components/UpgradeMEPSelector.cpp +++ b/Online/Dataflow/src/components/UpgradeMEPSelector.cpp @@ -18,10 +18,10 @@ #define ONLINE_DATAFLOW_MEPSELECTOR_H // Framework include files -#include "Dataflow/EventRunable.h" -#include "Tell1Data/Tell1Decoder.h" -#include "PCIE40Data/pcie40.h" -#include "MBM/Requirement.h" +#include <Dataflow/EventRunable.h> +#include <Tell1Data/Tell1Decoder.h> +#include <PCIE40Data/pcie40.h> +#include <MBM/Requirement.h> // C/C++ include files #include <vector> @@ -99,17 +99,15 @@ namespace Online { #endif // ONLINE_DATAFLOW_MEPSELECTOR_H /// Framework includes -//#include "Dataflow/UpgradeMEPSelector.h" -#include "Dataflow/MBMClient.h" -#include "Dataflow/Incidents.h" -#include "Dataflow/Printout.h" -#include "Dataflow/Plugins.h" -#include "MBM/Consumer.h" -#include "MBM/mepdef.h" -#include "RTL/Lock.h" -#include "RTL/rtl.h" - -#include "PCIE40Data/pcie40decoder.h" +#include <Dataflow/MBMClient.h> +#include <Dataflow/Incidents.h> +#include <Dataflow/Printout.h> +#include <Dataflow/Plugins.h> +#include <MBM/Consumer.h> +#include <MBM/mepdef.h> +#include <RTL/rtl.h> + +#include <PCIE40Data/pcie40decoder.h> // C/C++ include files #include <set> diff --git a/Online/Dataflow/src/framework/DiskReader.cpp b/Online/Dataflow/src/framework/DiskReader.cpp index a0140058c75e0f3105b6cc3cfe6a66eba6c011f0..06f11c39baf20df729c2e82a6f459b211d0952d0 100644 --- a/Online/Dataflow/src/framework/DiskReader.cpp +++ b/Online/Dataflow/src/framework/DiskReader.cpp @@ -88,6 +88,14 @@ void DiskReader::go_handler(void* tag, void* address, int* size) { } } +/// DIM command service callback +void DiskReader::run_number_change_handler(void* tag, void* address, int* size) { + if ( address && tag && *size > 0 ) { + DiskReader* rdr = *(DiskReader**)tag; + rdr->m_runNumberValue = *(int*)address; + } +} + /// DIM service update handler void DiskReader::run_no_update(void* tag, void** buf, int* size, int* first) { DiskReader* h = *(DiskReader**)tag; @@ -101,9 +109,7 @@ void DiskReader::run_no_update(void* tag, void** buf, int* size, int* first) { /// Standard Constructor DiskReader::DiskReader(const string& nam, DataflowContext& ctxt) - : DataflowComponent(nam, ctxt), m_receiveEvts(false), m_lock(0), - m_producer(0), m_eventsIN(0), m_evtCountFile(0), m_runSvcID(0), m_currentRun(0), - m_goSvcID(0), m_goValue(0), m_disabled(false), m_goto_paused(false), m_mbmInfos(0) + : DataflowComponent(nam, ctxt) { declareProperty("InputType", m_inputType = AUTO_INPUT_TYPE ); declareProperty("Buffer", m_buffer = "Mep"); @@ -130,7 +136,7 @@ DiskReader::DiskReader(const string& nam, DataflowContext& ctxt) declareProperty("MMapFiles", m_mmapFiles = 0); declareProperty("ReuseFile", m_reuse_file = false); declareProperty("PatchOdin", m_patch_odin = 0); - + declareProperty("RunNumberService", m_runNumberService = ""); declareProperty("Stream", m_stream = "RAW"); declareProperty("RunType", m_runType = ""); declareProperty("PartitionName", m_partitionName = "LHCb"); @@ -223,9 +229,10 @@ int DiskReader::initialize() { subscribeIncident("DAQ_CANCEL"); subscribeIncident("DAQ_STOP_TRIGGER"); subscribeIncident("DAQ_START_TRIGGER"); - declareMonitor("Events","IN", m_eventsIN=0, "Number of events read"); - declareMonitor("Events","OUT", m_eventsOUT=0, "Number of events processed"); - declareMonitor("EvtCountFile", m_evtCountFile=0, "Number of events processed from current input"); + declareMonitor("Events","IN", m_eventsIN=0, "Number of events read"); + declareMonitor("Events","OUT", m_eventsOUT=0, "Number of events processed"); + declareMonitor("EvtCountFile", m_evtCountFile=0, "Number of events processed from current input"); + m_currentRun = 0; ::lib_rtl_lock(m_lock); // m_files.clear(); @@ -237,7 +244,11 @@ int DiskReader::initialize() { } string nam = RTL::processName() + "/CurrentRunNumber"; m_runSvcID = ::dis_add_service(nam.c_str(),"I",0,0,run_no_update,(long)this); - + if ( !m_runNumberService.empty() ) { + m_runNumberSvcID = ::dic_info_service(m_runNumberService.c_str(),MONITORED,0,0,0, + run_number_change_handler,(long)this,0,0); + declareMonitor("RunNumberValue", m_runNumberValue, "Run number as received from DIM service"); + } // Buffer information blocks if ( m_mbmNames.empty() ) m_mbmNames.push_back(m_buffer); m_mbmInfos = new MBM::BufferInfo[m_mbmNames.size()]; @@ -266,6 +277,10 @@ int DiskReader::finalize() { ::dic_release_service(m_goSvcID); m_goSvcID = 0; } + if ( m_runNumberSvcID ) { + ::dic_release_service(m_runNumberSvcID); + m_runNumberSvcID = 0; + } m_receiveEvts = false; m_goto_paused = false; m_goValue = GO_DONT_PROCESS; @@ -287,6 +302,18 @@ int DiskReader::start() { m_goto_paused = false; m_receiveEvts = true; m_goValue = m_goService.empty() ? GO_PROCESS : GO_DONT_PROCESS; + if ( !m_runNumberService.empty() ) { + int retry = 0; + while ( m_runNumberValue <= 0 && ++retry < 1000 ) { + ::lib_rtl_sleep(100); + if ( (retry%25) == 0 ) { + warning("Waiting for run number update......."); + } + } + if ( m_runNumberValue <= 0 ) { + return error("Failed to access run number service"); + } + } ::lib_rtl_unlock(m_lock); return DF_SUCCESS; } @@ -557,7 +584,7 @@ DiskReader::load_event_data(RawFile::Allocator& allocator, RawFile& file) { return { size_t(data_size), 1, RawFile::MEP_INPUT_TYPE }; } // - // Now check for MDF format: 3 times same size + // Now check for MDF format: 3 times same size at the beginning of the record auto* mdf_hdr = (EventHeader*)size; if ( mdf_hdr->is_mdf() ) { int num_evts = 1; @@ -761,31 +788,40 @@ int DiskReader::declare_mbm_data(MBM::BufferInfo* mbm_info, const char* fname, c #include <Tell1Data/RunInfo.h> namespace { - bool _patch_odin_pcie40(void* data_ptr, size_t /* length */, int num) { + + bool _patch_odin_pcie40(void* data_ptr, size_t /* length */, int num, int external_runno) { using namespace pcie40; static uint32_t curr_run = 0; - static int32_t num_evts = 0; - mep_header_t* mep = (mep_header_t*)data_ptr; - std::size_t num_fragments = mep->num_source; + static int32_t num_evts = 0; + mep_header_t* mep = (mep_header_t*)data_ptr; + std::size_t num_fragments = mep->num_source; + if ( num_fragments > 0 ) { std::size_t packing = mep->multi_fragment(0)->packingFactor(); if ( packing > 0 ) { for(uint32_t i=0; i<num_fragments; ++i) { - const auto* mfp = mep->multi_fragment(i); + auto* mfp = mep->multi_fragment(i); if ( mfp->is_valid() && *mfp->types() == pcie40::bank_t::ODIN ) { - const frontend_data_t *curr = mfp->data(); - const uint16_t *lens = mfp->sizes(); - const std::size_t align = mfp->header.alignment; - if( 0 == curr_run || num_evts > num ) { - auto* sodin = (pcie40::sodin_t*)curr; - curr_run = sodin->run_number(); + frontend_data_t *curr = mfp->data(); + const uint16_t *lens = mfp->sizes(); + const uint8_t version = mfp->header.version; + const std::size_t align = mfp->header.alignment; + if ( external_runno > 0 ) { + curr_run = external_runno; + num_evts = 0; + } + else if( 0 == curr_run || num_evts > num ) { + curr_run = (version < 7) + ? curr->begin<RunInfo>()->run_number() + : curr->begin<pcie40::sodin_t>()->run_number(); num_evts = 0; } for (std::size_t j=0, n=mfp->packingFactor(); j<n; ++j, ++lens) { - auto* sodin = (pcie40::sodin_t*)curr; auto length = *lens; ++num_evts; - sodin->_run_number = curr_run; + (version < 7) + ? curr->begin<RunInfo>()->Run = curr_run + : curr->begin<pcie40::sodin_t>()->_run_number = curr_run; curr = curr->next(length, align); } return true; @@ -796,26 +832,30 @@ namespace { return false; } - bool _patch_odin_tell1(void* data_ptr, size_t length, int num) { + bool _patch_odin_tell1(void* data_ptr, size_t length, int num, int external_runno) { static uint32_t curr_run = 0; - static int32_t num_evts = 0; + static int32_t num_evts = 0; uint8_t* start = (uint8_t*)data_ptr; uint8_t* end = start + length; + while ( start < end ) { - const EventHeader* header = (const EventHeader*)start; - long evt_len = header->size0(); - uint8_t* evt_start = start + header->sizeOf(header->headerVersion()); - uint8_t* evt_end = start + evt_len; + const EventHeader* header = (const EventHeader*)start; + auto [evt_start, evt_end] = header->data_frame(); + long evt_len = header->size0(); if ( !header->is_mdf() ) return false; else if ( evt_len <= 0 ) return false; - if( 0==curr_run || num_evts > num ) { + if ( external_runno > 0 ) { + curr_run = external_runno; + num_evts = 0; + } + else if ( 0==curr_run || num_evts > num ) { curr_run = header->subHeader().H1->runNumber(); num_evts = 0; } - while(evt_start < evt_end ) { + while ( evt_start < evt_end ) { Tell1Bank* bank = (Tell1Bank*)evt_start; int len = bank->totalSize(); if ( len <= 0 ) { @@ -823,14 +863,9 @@ namespace { } if ( bank->type() == Tell1Bank::ODIN ) { ++num_evts; - if ( bank->version() < 7 ) { - RunInfo* o2 = (RunInfo*)bank->data(); - o2->Run = curr_run; - } - else { - pcie40::sodin_t* o2 = (pcie40::sodin_t*)bank->data(); - o2->_run_number = curr_run; - } + (bank->version() < 7) + ? bank->begin<RunInfo>()->Run = curr_run + : bank->begin<pcie40::sodin_t>()->_run_number = curr_run; } evt_start += len; } @@ -846,19 +881,19 @@ int DiskReader::handle_mbm_request(MBM::BufferInfo* mbmInfo, RawFile& input) { off_t pos = input.position(); auto load = this->load_event_data(allocator, input); - if ( m_patch_odin > 0 ) { - auto& e = m_producer->event(); + if ( this->m_patch_odin > 0 || this->m_runNumberValue > 0 ) { + auto& e = this->m_producer->event(); if ( load.type == RawFile::MDF_INPUT_TYPE ) - _patch_odin_tell1(e.data, load.length, m_patch_odin); + _patch_odin_tell1(e.data, load.length, this->m_patch_odin, this->m_runNumberValue); else if ( load.type == RawFile::MEP_INPUT_TYPE ) - _patch_odin_pcie40(e.data, load.length, m_patch_odin); + _patch_odin_pcie40(e.data, load.length, this->m_patch_odin, this->m_runNumberValue); } if ( load.packing <= 0 ) { input.reset(!m_reuse_file); return DF_CONTINUE; } - m_eventsIN += load.packing; - m_inputType = load.type; + this->m_eventsIN += load.packing; + this->m_inputType = load.type; int status = this->declare_mbm_data(mbmInfo, input.cname(), load); switch( status ) { @@ -981,9 +1016,9 @@ size_t DiskReader::DiskIO::scanFiles() { RawFile DiskReader::DiskIO::openFile() { string err; while ( files.size() > 0 ) { - auto i = files.begin(); - auto file = (*i).second; - files.erase(i); + auto iter = files.begin(); + auto file = (*iter).second; + files.erase(iter); int fd = map_file ? file.openMapped() : file.open(); if ( -1 == fd ) { if ( fail_delete != 0 ) { diff --git a/Online/Dataflow/src/framework/NETSelector.cpp b/Online/Dataflow/src/framework/NETSelector.cpp index f117f62ed4f7417d8673eae6e804818e401c21f5..c1ca0e91ef7b57dea1b8bba5b223966e4882df51 100755 --- a/Online/Dataflow/src/framework/NETSelector.cpp +++ b/Online/Dataflow/src/framework/NETSelector.cpp @@ -16,13 +16,12 @@ //========================================================================== /// Framework includes -#include "Dataflow/NETSelector.h" -#include "Dataflow/Incidents.h" -#include "CPP/TimeSensor.h" -#include "CPP/Event.h" -#include "RTL/Lock.h" -#include "WT/wtdef.h" -#include "MBM/mepdef.h" +#include <Dataflow/NETSelector.h> +#include <Dataflow/Incidents.h> +#include <CPP/TimeSensor.h> +#include <CPP/Event.h> +#include <WT/wtdef.h> +#include <MBM/bmstruct.h> // C/C++ include files #include <cstring> diff --git a/Online/Dataflow/src/framework/Receiver.cpp b/Online/Dataflow/src/framework/Receiver.cpp index 391fd16108fa7e7001dab17a80cdbe94e18ec7eb..34b660667bf698e9a82b97581cdd12a5965fb4f1 100755 --- a/Online/Dataflow/src/framework/Receiver.cpp +++ b/Online/Dataflow/src/framework/Receiver.cpp @@ -16,15 +16,13 @@ //========================================================================== /// Framework includes -#include "Dataflow/Receiver.h" -#include "Dataflow/MBMClient.h" -#include "Dataflow/Incidents.h" -#include "Tell1Data/Tell1Decoder.h" -#include "PCIE40Data/pcie40.h" -#include "DD4hep/Primitives.h" -#include "RTL/Lock.h" -#include "WT/wtdef.h" -#include "RTL/rtl.h" +#include <Dataflow/Receiver.h> +#include <Dataflow/MBMClient.h> +#include <Dataflow/Incidents.h> +#include <Tell1Data/Tell1Decoder.h> +#include <PCIE40Data/pcie40.h> +#include <WT/wtdef.h> +#include <RTL/rtl.h> // C/C++ include files #include <cstring> diff --git a/Online/Dataflow/src/framework/Sender.cpp b/Online/Dataflow/src/framework/Sender.cpp index 1be4d1bb5285410b3cf544b40d503541e04c6243..2793aaa8ea04468fd991759270658cdde64778fb 100755 --- a/Online/Dataflow/src/framework/Sender.cpp +++ b/Online/Dataflow/src/framework/Sender.cpp @@ -18,7 +18,6 @@ /// Framework includes #include <Dataflow/Sender.h> #include <Tell1Data/Tell1Decoder.h> -#include <RTL/Lock.h> #include <RTL/rtl.h> // C/C++ include files diff --git a/Online/EventBuilding/CMakeLists.txt b/Online/EventBuilding/CMakeLists.txt index 102bb598be4fd1cd1c0d291f3db539173773abbd..5e001f8b2dd95a0e7becfc0a2a39ca1cf3182862 100644 --- a/Online/EventBuilding/CMakeLists.txt +++ b/Online/EventBuilding/CMakeLists.txt @@ -32,6 +32,7 @@ else() message(STATUS "+======================================================================+") message(STATUS "| PCIE40 DAQ found. EventBuilding libraries shall be built. |") message(STATUS "+======================================================================+") + return() endif() #fpisani fixed find of external libraries diff --git a/Online/EventData/EventData/EventHandler.h b/Online/EventData/EventData/EventHandler.h index 167ab01f080fb97fe68a78a70d2adee9088d3ac0..8e708f90942720efd4b30dbafa84ee956a86edfd 100644 --- a/Online/EventData/EventData/EventHandler.h +++ b/Online/EventData/EventData/EventHandler.h @@ -45,7 +45,14 @@ namespace Online { DUMP_BANK_COLLECTIONS = 1 << 2, DUM_BANK_HEADERS = 1 << 3 }; - + enum error_flags { + NO_MDF_ERROR = 0, + INVALID_MDF_FORMAT = 1 << 1, + INVALID_MAGIC_PATTERN = 1 << 2, + INVALID_BANK_SIZE = 1 << 3, + TOO_MANY_BANKS = 1 << 31 + }; + protected: /// Reference to output logger std::unique_ptr<RTL::Logger> m_logger; @@ -75,7 +82,7 @@ namespace Online { void put_event(const std::string& loc, const evt_desc_t& event, size_t eid) const; /// Extract event record from normal/TAE event frame - evt_data_t create_event_data(const evt_desc_t& event, int bx) const; + std::pair<int,evt_data_t> create_event_data(const evt_desc_t& event, int bx) const; /// Extract error banks from the event data evt_data_t get_errors(event_traits::record_t event) const; @@ -84,7 +91,7 @@ namespace Online { evt_data_t get_errors(evt_desc_t& event) const; /// Extract Tell1 banks from event buffer - evt_data_t extract_tell1_banks(const unsigned char* start, const unsigned char* end) const; + std::pair<int,evt_data_t> extract_tell1_banks(const unsigned char* start, const unsigned char* end) const; /// Dump event structure to output void dump_event(evt_desc_t& e, int flags) const; @@ -112,12 +119,14 @@ namespace Online { /// Extract banks from event descriptor template <typename traits = void> - evt_data_t extract_banks(const evt_desc_t& event) const; + std::pair<int,evt_data_t> extract_banks(const evt_desc_t& event) const; /// On the occurrence of a TAE frame expand data and populate TES locations template <typename traits = void> size_t expand_tae(const std::string& prefix, const evt_desc_t& event) const; + template <typename T> T mdf_error_report(T return_value, int code) const; + }; } // End namespace Online #endif // GAUDIONLINE_EVENTHANDLER_H diff --git a/Online/EventData/EventData/EventOutput.h b/Online/EventData/EventData/EventOutput.h index 3a279291e8a91bb493b0f0243ef854563ebf3cd0..9320afc32adb7f5cd07ad1e66ed6be3efee83269 100644 --- a/Online/EventData/EventData/EventOutput.h +++ b/Online/EventData/EventData/EventOutput.h @@ -101,6 +101,8 @@ namespace Online { virtual bool sync() = 0; /// Shutdown the I/O medium virtual bool close() = 0; + /// Reposition output buffer to specified location + virtual size_t position(size_t new_position) = 0; }; typedef std::list<transaction_t*> transaction_collection_t; diff --git a/Online/EventData/src/EventAccess.cpp b/Online/EventData/src/EventAccess.cpp index 3365096b335cdc4b67a8e6ea6ced87ba62a584a8..2e030ad6b065d2bc654407856eca9574a47d4a0d 100644 --- a/Online/EventData/src/EventAccess.cpp +++ b/Online/EventData/src/EventAccess.cpp @@ -452,9 +452,7 @@ EventAccess::convertMultiMDF(datapointer_t startptr, size_t len) { bool stop = false; const char* err_msg = nullptr; const Tell1Bank* err_bank = nullptr; - size_t evt_len = header->size0(); - datapointer_t evt_start = start + header->sizeOf(header->headerVersion()); - datapointer_t evt_end = start + evt_len; + auto [evt_start, evt_end] = header->data_frame(); // Check bank's magic word and check on bank type and length if ( !checkHeader(header) ) { err_msg = "Event with BAD header bank encountered"; @@ -480,6 +478,7 @@ EventAccess::convertMultiMDF(datapointer_t startptr, size_t len) { if ( num_banks == 0 ) { ++monitor.eventsNoBanks; err_msg = "Event with ZERO banks encountered"; + skip = true; } else if ( num_banks > max_banks ) { ++monitor.eventsMaxBanks; @@ -489,10 +488,10 @@ EventAccess::convertMultiMDF(datapointer_t startptr, size_t len) { } } if ( err_msg || err_bank ) { - m_logger->error("SKIP EVENT: Buffer:%p Start:%p End:%p Size:(%d,%d,%d) HdrVsn:%u %s%s", + m_logger->error("SKIP EVENT: Buffer:%p Start:%p End:%p Size:(%d,%d,%d) HdrVsn:%u %s", (void*)startptr, (void*)start, (void*)evt_end, header->size0(), header->size1(), header->size2(), header->headerVersion(), - stop ? "---> STOP decoding" : "", skip ? "---> SKIP event" : ""); + stop ? "---> STOP decoding" : ""); if ( err_msg ) { m_logger->error(" %s",err_msg); } @@ -508,7 +507,7 @@ EventAccess::convertMultiMDF(datapointer_t startptr, size_t len) { events.second->emplace_back(header); events.first++; } - start += evt_len; + start += header->size0(); } catch(...) { m_logger->error("SKIP EVENT: Buffer:%p Start:%p End:%p Size:(%d,%d,%d) HdrVsn:%u", diff --git a/Online/EventData/src/EventHandler.cpp b/Online/EventData/src/EventHandler.cpp index 0ffb6c94a679d1b16922f70b419e2281b065b631..fafc9040bbfcec50dbf49ec98012132cd2dfa098 100644 --- a/Online/EventData/src/EventHandler.cpp +++ b/Online/EventData/src/EventHandler.cpp @@ -143,11 +143,33 @@ namespace { } return 0; } + + const char* _mdf_error_string(int code) { + switch(code) { + case EventHandler::NO_MDF_ERROR: + return "Success"; + case EventHandler::INVALID_MDF_FORMAT: + return "INVALID_MDF_FORMAT"; + case EventHandler::INVALID_MAGIC_PATTERN: + return "INVALID_MAGIC_PATTERN"; + case EventHandler::TOO_MANY_BANKS: + return "TOO_MANY_BANKS"; + case EventHandler::INVALID_BANK_SIZE: + return "INVALID_BANK_SIZE"; + default: + return "Unknown error"; + } + } } /// Online namespace declaration namespace Online { + template <typename T> T EventHandler::mdf_error_report(T return_value, int code) const { + m_logger->error("Bank error: %s -- action aborted.", _mdf_error_string(code)); + return return_value; + } + string EventHandler::_bx_offset(int bx) const { string offset; int cr = std::abs(bx); @@ -170,19 +192,18 @@ namespace Online { /// Access to ODIN banks from the event record std::pair<const BankHeader*, const void*> EventHandler::get_odin_bank(const evt_desc_t& event) const { - auto record = _record(event); + const auto record = _record(event); switch(event.second->type()) { case event_traits::tell1::data_type: { const auto* ev = record.tell1_event; if ( ev->is_mdf() ) { - const auto* start = record.data + ev->sizeOf(ev->headerVersion()); - const auto* end = record.data + ev->size(); - while ( start < end ) { - const Tell1Bank* bank = (Tell1Bank*)start; + auto data = ev->data_frame(); + while ( data.start < data.end ) { + const Tell1Bank* bank = (Tell1Bank*)data.start; if ( bank->type() == RawBank40::ODIN ) return {bank, bank->data()}; size_t len = bank->totalSize(); - start += len; + data.start += len; // Protect against infinite loop in case of data corruption if ( 0 == len ) break; } @@ -206,9 +227,7 @@ namespace Online { auto record = _record(event); switch(event.second->type()) { case event_traits::tell1::data_type: { - const event_traits::tell1::event_type& ev = *record.tell1_event; - const auto* start = record.data + ev.sizeOf(ev.headerVersion()); - const Tell1Bank* bank = reinterpret_cast<const Tell1Bank*>(start); + const Tell1Bank* bank = record.tell1_event->data<Tell1Bank>(); if ( bank->magic() == Tell1Bank::MagicPattern && bank->type() == Tell1Bank::TAEHeader ) { unsigned int count_bx = bank->size()/sizeof(int)/3; @@ -238,17 +257,14 @@ namespace Online { } /// Create raw event object from banks - EventHandler::evt_data_t + std::pair<int,EventHandler::evt_data_t> EventHandler::create_event_data(const evt_desc_t& event, int bx) const { switch(event.second->type()) { case event_traits::tell1::data_type: { const auto rec = _record(event); - const auto& evt = *rec.tell1_event; - auto* start = rec.data + evt.sizeOf(evt.headerVersion()); - auto* end = rec.data + evt.size(); - Tell1Bank* bank = (Tell1Bank*)start; - + auto frame = rec.tell1_event->data_frame(); + Tell1Bank* bank = (Tell1Bank*)frame.start; if ( bank->type() == Tell1Bank::TAEHeader ) { // Is it the TAE bank? const int* data = bank->begin<int>(); int count_bx = bank->size()/sizeof(int)/3; @@ -259,15 +275,15 @@ namespace Online { if ( crossing == bx ) { int off = data[3*idx+1]; int len = data[3*idx+2]; - start += bank->totalSize() + off; - return this->extract_tell1_banks(start, start+len); + frame.start += bank->totalSize() + off; + return this->extract_tell1_banks(frame.start, frame.start+len); } } m_logger->except("create_event_data: Wrong BX requested: %d [%d < bx < %d]", bx, -window, window); - return {}; + /// Will never get here: except throws exception! } - return this->extract_tell1_banks(start, end); + return this->extract_tell1_banks(frame.start, frame.end); } case event_traits::tell40::data_type: { @@ -282,20 +298,20 @@ namespace Online { for(const auto* b=bc->special_begin(); b != bc->special_end(); b = bc->next(b)) evt_data.emplace_back((BankHeader*)b, b->data()); } - return evt_data; + return make_pair(NO_MDF_ERROR, move(evt_data)); } default: m_logger->except("EventHandler","+++ Failed to access event structure [Invalid event type]."); } - return {}; + return std::pair<int,evt_data_t>(INVALID_MDF_FORMAT,{}); } /// Put bank container to specified location in the TES void EventHandler::put_event(const string& loc, const evt_desc_t& event, size_t eid) const { auto evt (this->create_event_data({event.first+eid, event.second}, 0)); - put_banks(loc, move(evt)); + put_banks(loc, move(evt.second)); } /// Output TAE frame in MDF format @@ -304,17 +320,16 @@ namespace Online { mask_t& mask, EventOutput& output) const { - event_traits::record_t record = _record(event); - const event_traits::tell1::event_type& evt = *record.tell1_event; - auto* start = record.data + evt.sizeOf(evt.headerVersion()); - Tell1Bank* bank = (Tell1Bank*)start; + const event_traits::record_t record = _record(event); + const event_traits::tell1::event_type* evt = record.tell1_event; + const Tell1Bank* bank = evt->data<Tell1Bank>(); /// We have here directly a TAE frame. Just copy it to the output if ( bank->type() == Tell1Bank::TAEHeader ) { // Is it the TAE bank? - size_t data_len = evt.sizeOf(evt.headerVersion()) + evt.size(); - auto* tr = output.getTransaction(data_len); - auto* ev_hdr = tr->get<EventHeader>(); - auto daq = ev_hdr->subHeader().H1->triggerMask(); + size_t data_len = evt->size0(); + auto* tr = output.getTransaction(data_len); + auto* ev_hdr = tr->get<EventHeader>(); + auto daq = ev_hdr->subHeader().H1->triggerMask(); unsigned int m[] = { daq[0], daq[1], daq[2], daq[3] }; _update_mask(m, mask); @@ -368,7 +383,7 @@ namespace Online { if ( !tr ) { m_logger->except("Event output failed [Cannot reserve output space]"); } - + size_t buffer_position = tr->used_bytes(); unsigned int m[] = { ~0x0U, ~0x0U, ~0x0U, ~0x0U }; _update_mask(m, mask); @@ -400,8 +415,13 @@ namespace Online { } for(int hw=half_window, iw=-hw; iw <= hw; ++iw) { size_t bank_len, sub_len = 0, num_bank = 0; - evt_data_t evt = this->create_event_data(event, iw); - for( auto& dsc : evt ) { + auto evt = this->create_event_data(event, iw); + if ( evt.first != NO_MDF_ERROR ) { + m_logger->warning("output_tae: Invalid TAE subevent at position %d --> drop",iw); + tr->position(buffer_position); + return 0; + } + for( auto& dsc : evt.second ) { auto* bank = dsc.first; if ( bank->magic() != traits::bank_type::MagicPattern ) { m_logger->warning("Bad bank: %d %ld transaction length:%ld", @@ -563,8 +583,12 @@ namespace Online { if ( central && half_window > 0 ) { return this->output_tae<traits>(event, mask, output); } - evt_data_t data = this->create_event_data(event, 0); - return this->output_mdf<traits>(data, mask, requireODIN, output); + auto data = this->create_event_data(event, 0); + if ( data.first != NO_MDF_ERROR ) { + m_logger->error("Bank error: %s -- action aborted.", _mdf_error_string(data.first)); + return 0; + } + return this->output_mdf<traits>(data.second, mask, requireODIN, output); } /// Output PCIE40 event in MDF format @@ -703,12 +727,13 @@ namespace Online { } /// Create raw event bank descriptors from raw buffer - EventHandler::evt_data_t + pair<int,EventHandler::evt_data_t> EventHandler::extract_tell1_banks(const unsigned char* start_ptr, const unsigned char* end_ptr) const { const auto* start = start_ptr, *end = end_ptr; size_t num_banks = 0, max_banks = 3000; + int error = NO_MDF_ERROR; evt_data_t evt_data; evt_data.reserve(1024); while ( start < end ) { @@ -718,6 +743,7 @@ namespace Online { "Invalid bank", "Bad magic pattern", start_ptr, start, end_ptr); m_logger->error("extract_banks: %s", Tell1Printout::bankHeader(bank).c_str()); + error = INVALID_MAGIC_PATTERN; break; } evt_data.emplace_back(bank, bank->data()); @@ -728,36 +754,35 @@ namespace Online { if ( ++num_banks < max_banks ) continue; m_logger->error("Exceeded maximum number of banks: %ld > %ld [%s]", num_banks, max_banks, "Banks were dropped"); + error = TOO_MANY_BANKS; break; } - return evt_data; + return make_pair(error,move(evt_data)); } /// Extract banks from event descriptor - template <> EventHandler::evt_data_t + template <> pair<int,EventHandler::evt_data_t> EventHandler::extract_banks<event_traits::tell1>(const evt_desc_t& e) const { const auto record(e.second->at(e.first)); - const event_traits::tell1::event_type& event = *record.tell1_event; - if ( event.is_mdf() ) { - auto* start = record.data + event.sizeOf(event.headerVersion()); - auto* end = record.data + event.size(); - return this->extract_tell1_banks(start, end); + if ( record.tell1_event->is_mdf() ) { + auto frame = record.tell1_event->data_frame(); + return this->extract_tell1_banks(frame.start, frame.end); } m_logger->except("Attempt to extract Tell1 banks from non-Tell1 frame."); - return {}; + return pair<int,evt_data_t>(INVALID_MDF_FORMAT,{}); } /// Extract banks from event descriptor - template <> EventHandler::evt_data_t + template <> pair<int,EventHandler::evt_data_t> EventHandler::extract_banks<event_traits::tell40>(const evt_desc_t& event) const { const auto record(event.second->at(event.first)); - const event_traits::tell40::event_type& e = *record.tell40_event; + const event_traits::tell40::event_type* e = record.tell40_event; evt_data_t evt_data; evt_data.reserve(1024); - for(size_t i=0; i < e.num_bank_collections(); ++i) { - const auto* bc = e.bank_collection(i); + for(size_t i=0; i < e->num_bank_collections(); ++i) { + const auto* bc = e->bank_collection(i); for(const auto* b=bc->begin(); b != bc->end(); b = bc->next(b)) { evt_data.emplace_back((BankHeader*)b, b->data()); } @@ -765,11 +790,11 @@ namespace Online { evt_data.emplace_back((BankHeader*)b, b->data()); } } - return evt_data; + return make_pair(NO_MDF_ERROR,move(evt_data)); } /// Extract banks from event descriptor - template <> EventHandler::evt_data_t + template <> pair<int,EventHandler::evt_data_t> EventHandler::extract_banks<void>(const evt_desc_t& event) const { switch(event.second->type()) { @@ -780,7 +805,7 @@ namespace Online { default: m_logger->error("+++ Algorithm failed [Invalid event type]."); } - return {}; + return pair<int,evt_data_t>(INVALID_MDF_FORMAT,{}); } /// Dump event structure to output @@ -791,30 +816,30 @@ namespace Online { bool dump_bank_headers = (flags&DUM_BANK_HEADERS) != 0; bool dump_bank_collections = (flags& DUMP_BANK_COLLECTIONS) != 0; if ( dump_events ) { - evt_data_t evt_data = extract_banks(e); - if ( evt_data.empty() ) { + auto evt_data = extract_banks(e); + if ( evt_data.second.empty() ) { return; } if ( dump_bank_collections ) { log->always("+====================================================================="); } size_t data_len = 0; - std::map<int,size_t> bank_types, bank_data_len; - for(const auto& b : evt_data) { + map<int,size_t> bank_types, bank_data_len; + for( const auto& b : evt_data.second ) { data_len += b.first->size(); bank_types[b.first->type()] += 1; bank_data_len[b.first->type()] += b.first->size(); } log->always("| ++ Event[%s]: %ld banks %ld bytes", e.second->type()==event_traits::tell1::data_type ? "TELL1" : "PCIE40", - evt_data.size(), data_len); + evt_data.second.size(), data_len); if ( dump_bank_collections ) { for ( const auto& t : bank_types) { log->always("| ++====> Bank collection: %3d %-15s Number: %4d %6ld", t.first, Online::Tell1Printout::bankType(t.first).c_str(), t.second, bank_data_len[t.first]); if ( dump_bank_headers ) { - for(const auto& b : evt_data) { + for( const auto& b : evt_data.second ) { if ( b.first->type() == t.first ) { log->always("+++ %s", Online::Tell1Printout::bankHeader(b.first).c_str()); } @@ -827,10 +852,10 @@ namespace Online { /// On the occurrence of a TAE frame expand data and populate TES locations template <> - size_t EventHandler::expand_tae<event_traits::tell1>(const std::string& prefix, + size_t EventHandler::expand_tae<event_traits::tell1>(const string& prefix, const evt_desc_t& event) const { - size_t eid = event.first; + size_t eid = event.first; const auto* hdr = event.second->at(eid).tell1_event; if ( hdr && hdr->is_mdf() ) { const auto* tae = (const Tell1Bank*)hdr->data(); @@ -840,8 +865,11 @@ namespace Online { } if ( tae->type() != Tell1Bank::TAEHeader ) { const uint8_t* start = hdr->data(); - evt_data_t banks(this->extract_tell1_banks(start, start+hdr->size())); - this->put_banks(prefix + "/Central", move(banks)); + auto banks(this->extract_tell1_banks(start, start+hdr->size())); + if ( banks.first != NO_MDF_ERROR ) { + return 0; + } + this->put_banks(prefix + "/Central", move(banks.second)); return 1; } const int* data = tae->begin<int>(); @@ -856,13 +884,16 @@ namespace Online { int off = data[3*idx+1]; int len = data[3*idx+2]; - evt_data_t banks(this->extract_tell1_banks(start+off, start+off+len)); + auto banks(this->extract_tell1_banks(start+off, start+off+len)); + if ( banks.first != NO_MDF_ERROR ) { + return mdf_error_report(0, banks.first); + } if ( bx < 0 ) - this->put_banks(pref_prev + _bx_offset(bx), move(banks)); + this->put_banks(pref_prev + _bx_offset(bx), move(banks.second)); else if ( bx > 0 ) - this->put_banks(pref_next + _bx_offset(bx), move(banks)); + this->put_banks(pref_next + _bx_offset(bx), move(banks.second)); else - this->put_banks(prefix + "/Central", move(banks)); + this->put_banks(prefix + "/Central", move(banks.second)); } return 2*half_win + 1; } @@ -872,7 +903,7 @@ namespace Online { /// On the occurrence of a TAE frame expand data and populate TES locations template <> - size_t EventHandler::expand_tae<event_traits::tell40>(const std::string& prefix, + size_t EventHandler::expand_tae<event_traits::tell40>(const string& prefix, const evt_desc_t& event) const { size_t eid = event.first; @@ -902,7 +933,7 @@ namespace Online { /// On the occurrence of a TAE frame expand data and populate TES locations template <> - size_t EventHandler::expand_tae<void>(const std::string& prefix, + size_t EventHandler::expand_tae<void>(const string& prefix, const evt_desc_t& event) const { switch(event.second->type()) { diff --git a/Online/EventData/src/FileEventOutput.cpp b/Online/EventData/src/FileEventOutput.cpp index 4c9ea338c42a7426c883d62e04ee7095655d12d5..bea04d320b943f10cbf74f2fabea71e309fdf384 100644 --- a/Online/EventData/src/FileEventOutput.cpp +++ b/Online/EventData/src/FileEventOutput.cpp @@ -38,6 +38,7 @@ public: RawFile file; std::unique_ptr<data_t[]> space; FileEventOutput* output {0}; + size_t position_ptr {0}; public: /// Default constructor @@ -58,6 +59,8 @@ public: virtual bool sync() override; /// Shutdown the I/O medium virtual bool close() override; + /// Reposition output buffer to specified location + virtual size_t position(size_t new_position) override; }; /// Allocate buffer to store contiguous junk of data @@ -85,6 +88,7 @@ bool FileEventOutput::file_transaction_t::sync() { } int ret = file.write(space.get(), length); if ( ret ) { + position_ptr += length; start = 0; length = 0; events = 0; @@ -101,6 +105,16 @@ bool FileEventOutput::file_transaction_t::close() { return true; } +/// Reposition output buffer to specified location +size_t FileEventOutput::file_transaction_t::position(size_t new_position) { + if ( file.isOpen() ) { + auto temp = file.position(); + file.position(new_position); + return temp; + } + return 0; +} + /// Standard constructor FileEventOutput::FileEventOutput(unique_ptr<RTL::Logger>&& logger) : EventOutput(move(logger), &config) diff --git a/Online/EventData/src/MBMEventOutput.cpp b/Online/EventData/src/MBMEventOutput.cpp index 63053f2cbc738c7e6ff4f84689b385962782c83d..099067c21654e374fb1dc516591d9f085f812b19 100644 --- a/Online/EventData/src/MBMEventOutput.cpp +++ b/Online/EventData/src/MBMEventOutput.cpp @@ -67,6 +67,8 @@ public: virtual bool sync() override; /// Shutdown the I/O medium virtual bool close() override; + /// Reposition output buffer to specified location + virtual size_t position(size_t new_position) override; /// Callback when space is availible (not really used) static int spaceAst(void* /* param */) { return MBM_NORMAL; @@ -151,6 +153,16 @@ bool MBMEventOutput::mbm_transaction_t::close() { return false; } +/// Reposition output buffer to specified location +size_t MBMEventOutput::mbm_transaction_t::position(size_t new_position) { + if ( new_position < size ) { + auto temp = length; + length = new_position; + return temp; + } + return length; +} + /// Standard constructor MBMEventOutput::MBMEventOutput(unique_ptr<RTL::Logger>&& logger) : EventOutput(move(logger), &config) diff --git a/Online/FarmConfig/job/AddersFromArchitecture.py b/Online/FarmConfig/job/AddersFromArchitecture.py index 877a6da36e3416ff8a695190c34322be0f7bcc41..897f3a777682c6ce33d625e3c14c92a31c5ea3ed 100644 --- a/Online/FarmConfig/job/AddersFromArchitecture.py +++ b/Online/FarmConfig/job/AddersFromArchitecture.py @@ -5,6 +5,7 @@ import Configurables from GaudiOnline import Application from GauchoAppl import GauchoApplConf +EventLoopMgr = Gaudi.Configurables.EventLoopMgr ApplicationMgr = Gaudi.Configuration.ApplicationMgr CounterDebugSvcs = ["DskWriter"] HistDebugSvcs = ["AligWrk"] @@ -25,144 +26,204 @@ def VictimNode(): if i.match(hname) != None: return True -def TaskListfromArch(arch, tasklist): - xmldoc = minidom.parse(arch) +def TaskListfromArch(arch): + tasklist = [] + xmldoc = minidom.parse(arch) itemlist = xmldoc.getElementsByTagName('task') -# tasklist = [] for s in itemlist: - nam = s.attributes['name'] -# if not nam.find('MEPR')>=0: - tasklist.append(s.attributes['name'].value) - -class AdderApp(Application): - def __init__(self, outputLevel, partitionName='OFFLINE', partitionID=0xFFFF, adders=[]): - import _fifo_log - Application.__init__(self, - outputLevel=outputLevel, - partitionName=partitionName, - partitionID=partitionID) - # First setup printing device: - self.config.logDeviceType = 'RTL::Logger::LogDevice' - self.config.logDeviceFormat = '%-8LEVEL %-24SOURCE' - self.config.logDeviceType = 'fifo' - _fifo_log.logger_set_tag(partitionName) - _fifo_log.logger_start() - # Now the rest: - self.config.numEventThreads = 0 - self.config.numStatusThreads = 0 - utgid = os.getenv("UTGID","") - self.config.autoStart = False - self.app = ApplicationMgr() - self.app.MessageSvcType = 'MessageSvc' - self.app.EvtSel = 'NONE' - self.app.EvtMax = -1 - self.app.AppName = utgid - self.app.HistogramPersistency = "NONE" - self.app.EvtSel = "NONE"; - self.app.ExtSvc = adders + nam = s.attributes['name'] + tasklist.append(s.attributes['name'].value) + return tasklist -def AddersfromTasks(tasklist, level, pname, dohostdns, alist): - if level=="1": - InDns = os.getenv("InDns","<dns>") - OutDns = os.getenv("OutDns","<dns>") - elif level=="2" or level=="2.1": +def AddersfromTasks(tasklist, level, pname, dohostdns): + alist = [] + if level == "2" or level == "Subfarm": InDns = os.getenv("InDns","<node>") OutDns = os.getenv("OutDns","mon01") - elif level=="2.0" or level=="2.1": + elif level == "2.0" or level=="2.1": InDns = os.getenv("InDns","<node>") OutDns = os.getenv("OutDns","mon01") elif level == "3": - InDns = os.getenv("InDns","hlt01") - OutDns = os.getenv("OutDns","mon01") + InDns = os.getenv("InDns","hlt01") + OutDns = os.getenv("OutDns","mon01") elif level == "3.1": - InDns = os.getenv("InDns","mon01") - OutDns = os.getenv("OutDns","mon01") - elif level == "4": - InDns = os.getenv("InDns","mon01") - OutDns = os.getenv("OutDns","mon01") - if level=="1": + InDns = os.getenv("InDns","mon01") + OutDns = os.getenv("OutDns","mon01") + + if level=="HltNode" or level == "EventBuilder": + InDns = os.getenv("InDns","<dns>") + OutDns = os.getenv("OutDns","<dns>") for t in tasklist: if 'NodeAdder' in t: continue if 'AligAdder' in t: continue - tn = str(t) - myname = "<part>_<node>_"+tn + task_name = str(t) + myname = "<part>_<node>_"+task_name - adder = GauchoApplConf.AdderSvc("C_"+tn) + adder = GauchoApplConf.AdderSvc("C_"+task_name) adder.InDNS = InDns adder.OutDNS = OutDns adder.MyName = myname - adder.PartitionName = pname - adder.TaskPattern = "<part>_<node>_"+tn - adder.ServicePattern = "MON_<part>_<node>_"+tn+"_(.*)/Counter/" - adder.RunAware = False - adder.AdderClass="counter" - adder.DebugOn=False + adder.PartitionName = pname + adder.TaskPattern = "<part>_<node>_"+task_name + adder.ServicePattern = "MON_<part>_<node>_"+task_name+"_(.*)/Counter/" + adder.RunAware = False + adder.AdderClass = "counter" + adder.DebugOn = False alist.append(adder) - adder = GauchoApplConf.AdderSvc("H_"+tn) + adder = GauchoApplConf.AdderSvc("H_"+task_name) adder.InDNS = InDns adder.OutDNS = OutDns adder.MyName = myname adder.PartitionName = pname - adder.TaskPattern = "<part>_<node>_"+tn - adder.ServicePattern = "MON_<part>_<node>_"+tn+"_(.*)/Histos/" + adder.TaskPattern = "<part>_<node>_"+task_name + adder.ServicePattern = "MON_<part>_<node>_"+task_name+"_(.*)/Histos/" adder.RunAware = False adder.AdderClass="hists" - # CAddSv.RunAware=True + # CAddSv.RunAware=True adder.DebugOn=False alist.append(adder) - elif level=="2.0" or level=="2.1": - tpatt="" - if level=="2.0": - nodpatt="<part>_[a-z][a-z]eb[0-9][0-9]"#_EBNodeAdder_" - tpatt=nodpatt+"_EBNodeAdder_" + elif level == "2.0" or level == "Subfarm": + if level == "2.0": + nodpatt="<part>_[a-z][a-z]eb[0-9][0-9]" + tpatt=nodpatt+"_EBAdder_" else: - nodpatt="<part>_<node>[0-9][0-9]"#_NodeAdder_" + nodpatt="<part>_<node>[0-9][0-9]" tpatt=nodpatt+"_NodeAdder_" for t in tasklist: - tn = str(t) - myname = "<part>_<node>_"+tn - adder = GauchoApplConf.AdderSvc("C_"+tn) + task_name = str(t) + myname = "<part>_<node>_"+task_name + adder = GauchoApplConf.AdderSvc("C_"+task_name) adder.InDNS = InDns adder.OutDNS = OutDns - # CAddSv.OutDNS = "fmc01" + # CAddSv.OutDNS = "fmc01" adder.MyName=myname adder.PartitionName = pname adder.TaskPattern = tpatt - adder.ServicePattern = "MON_"+nodpatt+"_"+tn+"/Counter/" + adder.ServicePattern = "MON_"+nodpatt+"_"+task_name+"/Counter/" adder.RunAware = False adder.AdderClass="counter" - # CAddSv.RunAware=True + # CAddSv.RunAware=True adder.DebugOn=False alist.append(adder) - adder = GauchoApplConf.AdderSvc("H_"+tn) - adder.InDNS = InDns - adder.OutDNS = OutDns - # CAddSv.OutDNS = "fmc01" - adder.MyName=myname - adder.PartitionName = pname - adder.TaskPattern = tpatt - adder.ServicePattern = "MON_"+nodpatt+"_"+tn+"/Histos/" - adder.RunAware = False - adder.AdderClass="hists" - # CAddSv.RunAware=True - adder.DebugOn=False + adder = GauchoApplConf.AdderSvc("H_"+task_name) + adder.InDNS = InDns + adder.OutDNS = OutDns + # CAddSv.OutDNS = "fmc01" + adder.MyName = myname + adder.PartitionName = pname + adder.TaskPattern = tpatt + adder.ServicePattern = "MON_"+nodpatt+"_"+task_name+"/Histos/" + adder.RunAware = False + adder.AdderClass = "hists" + # CAddSv.RunAware = True + adder.DebugOn = False + alist.append(adder) + + elif level=="TopAdder": + nodpatt = "<part>_hlt[0-2][0-9][0-9]" + tpatt = nodpatt + "_Adder_" + for t in tasklist: + task_name = str(t) + myname = "<part>_<node>_"+task_name + adder = GauchoApplConf.AdderSvc("C_"+task_name) + adder.InDNS = InDns + adder.OutDNS = OutDns + adder.MyName = myname + adder.PartitionName = pname + adder.TaskPattern = tpatt + adder.ServicePattern = "MON_"+nodpatt+"_"+task_name+"/Counter/" + adder.RunAware = False + adder.AdderClass = "counter" + adder.DebugOn = False + alist.append(adder) + adder = GauchoApplConf.AdderSvc("H_"+task_name) + adder.InDNS = InDns + adder.OutDNS = OutDns + adder.MyName = myname + adder.PartitionName = pname + adder.TaskPattern = tpatt + adder.ServicePattern = "MON_"+nodpatt+"_"+task_name+"/Histos/" + adder.RunAware = False + adder.AdderClass = "hists" + adder.DebugOn = False + adder.ReceiveTimeout = 12 + adder.IsSaver = True + adder.SaveInterval = 100 + adder.SaveonUpdate = False + adder.SaveRootDir = '/group/online/dataflow/cmtuser/Savesets' + adder.SaveSetTaskName= task_name alist.append(adder) + elif level == "TopSaver": + InDns = os.getenv("InDns","mon01") + OutDns = os.getenv("OutDns","mon01") + nodpatt = "<part>_hlt[0-2][0-9][0-9]" + tpatt = nodpatt + "_Adder_" + for t in tasklist: + task_name = str(t) + myname = "<part>_<node>_"+task_name + adder = GauchoApplConf.AdderSvc("H_"+task_name) + adder.InDNS = InDns + adder.OutDNS = OutDns + adder.MyName = myname + adder.PartitionName = pname + adder.TaskPattern = tpatt + adder.ServicePattern = "MON_"+nodpatt+'_'+task_name+'/Histos/' + adder.RunAware = False + adder.AdderClass = "hists" + adder.DebugOn = False + adder.ReceiveTimeout = 12 + adder.IsSaver = True + adder.SaveInterval = 900 + adder.SaveonUpdate = False + adder.SaveRootDir = '/group/online/dataflow/cmtuser/Savesets' + adder.SaveSetTaskName= task_name + alist.append(adder) + return alist + +class AdderApp(Application): + def __init__(self, outputLevel, partitionName='OFFLINE', partitionID=0xFFFF, adders=[]): + import _fifo_log + Application.__init__(self, + outputLevel=outputLevel, + partitionName=partitionName, + partitionID=partitionID) + #utgid = os.getenv("UTGID","") + # First setup printing device: + self.config.logDeviceType = 'RTL::Logger::LogDevice' + self.config.logDeviceFormat = '%-8LEVEL %-24SOURCE' + self.config.logDeviceType = 'fifo' + _fifo_log.logger_set_tag(partitionName) + _fifo_log.logger_start() + # Now the rest: + self.config.numEventThreads = 0 + self.config.numStatusThreads = 0 + self.config.autoStart = False + self.app = ApplicationMgr() + self.app.MessageSvcType = 'MessageSvc' + self.app.EvtSel = 'NONE' + self.app.EvtMax = -1 + self.app.AppName = "" # utgid + self.app.HistogramPersistency = "NONE" + self.app.EvtSel = "NONE" + self.app.ExtSvc = adders + EventLoopMgr().Warnings = False + + import OnlineEnvBase -tasklist = [] -adderlist = [] -vnode = VictimNode() -## part = os.getenv("PARTITION",part) +vnode = VictimNode() part = OnlineEnvBase.PartitionName -## arch = os.getenv("ARCHITECTURE",arch) arch = OnlineEnvBase.WorkerArchitecture hostdns = False level = os.getenv("LEVEL","1") -print("Adder: Level: %s Partition: %s Architecture: %s"%(level, part, arch)) -TaskListfromArch(arch, tasklist) -AddersfromTasks(tasklist,level,part,hostdns,adderlist) +print("[INFO] Adder: Level: %s Partition: %s Architecture: %s"%(level, part, arch)) + +tasklist = TaskListfromArch(arch) +adderlist = AddersfromTasks(tasklist,level,part,hostdns) + + app = AdderApp(outputLevel=OnlineEnvBase.OutputLevel,partitionName=part,adders=adderlist) diff --git a/Online/FarmConfig/job/BU.sh b/Online/FarmConfig/job/BU.sh index ed0c227b4e8fa783ee4c8d900f1636442f66b98d..9e72a27d4dd6a7de6007b9b0d873287ee12aee9b 100755 --- a/Online/FarmConfig/job/BU.sh +++ b/Online/FarmConfig/job/BU.sh @@ -12,7 +12,10 @@ unset PYTHONPATH; unset PYTHONHOME; eval `/usr/bin/python2 -c "import os;s=os.environ['UTGID'];print 'export BU_OPTIONS='+s[s.find('BU'):]+'.opts'"`; -. /group/online/dataflow/EventBuilder/EventBuilderRelease/setup.x86_64-centos7-gcc9-opt.vars; +#. /group/online/dataflow/EventBuilder/EventBuilderRelease/setup.x86_64-centos7-gcc9-opt.vars; +#. /group/online/dataflow/EventBuilder/EventBuilderRelease/setup.x86_64_v2-centos7-gcc10-do0.vars; +. /group/online/dataflow/EventBuilder/EventBuilderRelease/setup.x86_64_v2-centos7-gcc10-opt.vars; +# . /group/online/dataflow/EventBuilder/EventBuilderRelease/setup.${CMTCONFIG}.vars; cd ${FARMCONFIGROOT}/job; # `dataflow_task Class1` -opts=../../EventBuilding/options/${BU_OPTIONS} ${AUTO_STARTUP} ${DEBUG_STARTUP}; diff --git a/Online/FarmConfig/job/BWDivision.py b/Online/FarmConfig/job/BWDivision.py deleted file mode 100755 index b9be64c393e2b2635a384e25667a3ce04251efc4..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/BWDivision.py +++ /dev/null @@ -1,7 +0,0 @@ -import sys -import os -import Criteria - -Crits=Criteria.Criteria() -Crits.__init__() -Crits.exclRuns = [174819, 174822, 174823, 174824, 175266, 175269, 175359, 175363, 175364, 175385, 175431, 175434, 175492, 175497, 175499, 175580, 175584, 175585, 175589] diff --git a/Online/FarmConfig/job/BusyMon.sh b/Online/FarmConfig/job/BusyMon.sh deleted file mode 100755 index 6b9f5677140cdcecb20a52fef2ad28ab4976856b..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/BusyMon.sh +++ /dev/null @@ -1,8 +0,0 @@ -. ~beat/.bashrc -pkill -fe GaudiTest -cd /group/online/cmtuser -genv -cd OnlineDev_v7r2 -. setup.x86_64-centos7-gcc9-opt.vars -export DIM_DNS_NODE=ecs03 -`which python` `which gaudirun.py` --application=Online::OnlineApplication ./GaudiTest.py diff --git a/Online/FarmConfig/job/BusyPub.sh b/Online/FarmConfig/job/BusyPub.sh deleted file mode 100755 index 8e7c90cf50af1b387398604e5add9c5118013535..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/BusyPub.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -cd /group/online/dataflow/cmtuser -export User_release_area=`pwd`; -export CMTPROJECTPATH=`pwd`:${CMTPROJECTPATH}; -source OnlineRelease/setup.x86_64-centos7-gcc62-do0.vars -cd OnlineRelease/Online/FarmConfig/job -export msg_svc=LHCb::FmcMessageSvc -export HOST=`hostname` -export UTGID=GEN_${HOST}_BusyPub -export LOGFIFO=/run/fmc/logGaudi.fifo -GaudiOnlineExe.exe libGaudiOnline.so OnlineTask -msgsvc=$msg_svc -tasktype=LHCb::Class2Task -main=/group/online/dataflow/templates/options/Main.opts -opts=../options/BusyPub.opts -auto diff --git a/Online/FarmConfig/job/Calo.py b/Online/FarmConfig/job/Calo.py deleted file mode 100755 index cffdae1646859de2d06656fc86370e92550ed94d..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/Calo.py +++ /dev/null @@ -1,133 +0,0 @@ -from builtins import range -import sys -import os -import Criteria -import time -import re -Crits=Criteria.Criteria() -Crits.__init__() -Crits.keepRuns=[ -205986,205988,205989,205991,205992,205994,205995,205997,205999,206000,206061,206107,206108,206109,206110, -206112,206113,206115,206116,206117,206117,206117,206119,206120,206121,206122,206162,206165,206167,206170, -206171,206172,206173,206174,206175,206176,206177,206180,206181,206184,206185,206188,206189,206191,206193, -206194,206195,206198,206202,206203,206264,206265,206293,206294,206296,206297,206298,206302,206303,206304, -206305,206323,206325,206326,206337,206339,206340,206341,206342,206344,206345,206346,206370,206371,206372, -206374,206375,206376,206377,206378,206379,206400,206402,206404,206404,206404,206404,206404,206404,206404, -206442,206444,206445,206446,206447,206448,206449,206450,206451,206452,206453,206454,206455,206456,206535, -206537,206538,206539,206541,206543,206544,206545,206546,206547,206548,206549,206550,206551,206572,206574, -206575,206576,206579,206581,206583,206584,206585,206586,206587,206589,206590,206592,206593,206594,206595, -206597,206598,206617,206637,206638,206641,206642,206643,206644,206645,206675,206677,206678,206680,206681, -206682,206684,206685,206687,206688,206689,206690,206692,206693,206704,206708,206709,206711,206712,206713, -206716,206717,206723,206725,206726,206754,206758,206759,206760,206763,206765,206766,206767,206768,206772, -206773,206774,206788,206791,206792,206793,206852,206854,206857,206858,206861,206863,206864,206875,206877, -206878,206879,206882,206883,206884,206885,206886,206887,206888,206889,206890,206893,206894,206896,206897, -206898,206899,206900,206901,206902,206903,206904,206905,206906,206907,206908,206909,206910,206911,206912, -206942,206945,206946,206947,206950,206951,206953,206954,206955,206957,206959,206961,206962,206963,206964, -206965,207001,207008,207010,207012,207013,207013,207015,207016,207019,207021,207022,207023,207024,207025, -207026,207027,207028,207029,207030,207045,207047,207048,207050,207053,207054,207056,207057,207058,207059, -207060,207061,207062,207063,207064,207065,207066,207067,207068,207069,207072,207073,207074,207075,207076, -207077,207079,207080,207081,207083,207084,207085,207101,207102,207104,207106,207123,207125,207127,207131, -207177,207180,207181,207185,207186,207187,207190,207191,207194,207197,207198,207200,207201,207202,207204, -207205,207206,207208,207209,207210,207213,207214,207215,207216,207217,207218,207219,207220,207222,207223, -207224,207225,207226,207227,207228,207229,207231,207232,207233,207234,207235,207236,207237,207238,207239, -207240,207241,207243,207244,207245,207246,207247,207248,207249,207262,207266,207267,207268,207269,207273, -207274,207275,207276,207278,207279,207280,207281,207282,207283,207284,207297,207298,207300,207302,207303, -207305,207306,207307,207308,207309,207310,207314,207318,207331,207340,207341,207342,207343,207346,207350, -207355,207356,207357,207358,207359,207360,207361,207363,207376,207379,207384,207385,207386,207387,207388, -207389,207390,207391,207393,207409,207413,207414,207415,207419,207429,207442,207444,207446,207465,207466, -207471,207472,207497,207498,207501,207505,207506,207509,207510,207513,207515,207517,207518,207519,207521, -207522,207523,207524,207525,207526,207527,207528,207542,207545,207547,207548,207550,207551,207552,207554, -207555,207556,207557,207558,207577,207579,207581,207582,207583,207586,207587,207623,207675,207677,207678, -207735,207739,207742,207745,207747,207748,207749,207750,207752,207814,207819,207826,207827,207829,207831, -207833,207839,207841,207842,207845,207847,207849,207850,207858,207860,207861,207862,207874,207878,207880, -207881,207884,207919,207922,207924,207925,207930,207931,207932,207934,207939,207940,207941,207944,207945, -207946,207947,207949,207950,207952,207981,207983,207987,207988,207989,207991,207994,207997,207999,208000, -208014,208016,208021,208022,208028,208032,208033,208034,208035,208036,208037,208039,208040,208043,208045, -208046,208049,208051,208052,208063,208066,208071,208073,208075,208077,208079,208081,208083,208085,208086, -208088,208091,208093,208095,208097,208098,208111,208113,208117,208122,208124,208126,208128,208130,208133, -208135,208138,208140,208143,208145,208148,208168,208172,208173,208177,208183,208185,208186,208189,208192, -208194,208195,208198,208200,208201,208202,208203,208204,208206,208207,208217,208218,208319,208320,208322, -208325,208327,208328,208331,208347,208348,208351,208352,208355,208357,208358,208359,208360,208361,208363, -208364,208366,208384,208394,208396,208398,208399,208403,208404,208405,208406,208407,208409,208411,208414, -208422,208425,208426,208430,208431,208432,208433,208434,208435,208436,208458,208459,208461,208463,208464, -208465,208466,208468,208469,208471,208473,208476,208477,208478,208479,208481,208482,208483,208484,208485, -208487,208488,208489,208490,208491,208492,208493,208494,208529,208532,208606,208610,208611,208613,208614, -208622,208623,208630,208631,208632,208640,208641,208644,208645,208646,208651,208653,208655,208657,208659, -208660,208661,208662,208663,208674,208675,208684,208687,208688,208689,208690,208691,208692,208695,208696, -208697,208698,208699,208700,208701,208703,208704,208705,208741,208743,208745,208748,208750,208752,208753, -208754,208755,208756,208760,208787,208790,208791,208792,208795,208814,208816,208818,208819,208823,208825, -208826,208827,208828,208829,208830,208831,208832,208833,208834,208835,208850,208853,208859,208864,208865, -208866,208867,208869,208870,208871,208872,208875,208876,208890,208893,208898,208903,208907,208908,208909, -208910,208911,208912,208913,208914,208915,208916,208917,208918,208919,208920,208921,208922,208923,208924, -208926,208927,208928,208929,208930,208932,208934,208935,208938,208940,208942,208943,208944,208948,208950, -208952,208954,208957,208977,208979,208983,208987,208990,208991,208992,208996,208999,209001,209003,209005, -209007,209009,209011,209028,209032,209034,209038,209040,209041,209043,209044,209046,209048,209049,209051, -209052,209054,209055,209056,209058,209060,209061,209062,209063,209064,209065,209066,209067,209068,209069, -209070,209139,209140,209143,209145,209150,209151,209152,209153,209154,209155,209156,209157,209158,209193, -209194,209196,209260,209262,209263,209267,209270,209271,209276,209280,209283,209285,209286,209287,209289, -209291,209292,209294,209295,209300,209302,209305,209353,209355,209359,209360,209361,209362,209365,209367, -209379,209382,209383,209384,209388,209389,209390,209391,209422,209423,209433,209434,209436,209438,209439, -209443,209444,209445,209446,209448,209449,209450,209458,209459,209460,209461,209462,209463,209554,209557, -209561,209562,209563,209564,209565,209566,209567,209589,209592,209596,209597,209599,209628,209630,209632, -209633,209662,209665,209669,209670,209671,209672,209673,209674,209675,209676,209677,209678,209679,209680, -209681,209693,209696,209700,209701,209702,209703,209704,209705,209706,209707,209708,209709,209710,209711, -209712,209713,209715,209716,209724,209726,209728,209730,209733,209735,209770,209772,209773,209774,209775, -209798,209801,209804,209806,209807,209808,209809,209810,209811,209812,209813,209814,209815,209817,209818, -209819,209836,209838,209840,209844,209845,209846,209847,209848,209849,209850,209851,209852,209853,209854, -209855,209856,209857,209858,209859,209860,209861,209862,209863,209864,209888,209890,209891,209895,209896, -209900,209901,209902,209903,209904,209905,209906,209907,209908,209909,209922,209925,209926,209930,209930, -209931,209932,209933,209934,209935,209936,209946,209948,209950,209955,209956,209957,209958,209959,209960, -209961,209962,210015,210017,210019,210047,210051,210052,210053,210055,210056,210057,210058,210059,210061, -210062,210063,210064,210065,210066,210067,210068,210069,210072,210074,210075,210085,210088,210092,210093, -210094,210095,210096,210097,210098,210099,210100,210101,210102,210103,210105,210106,210107,210108,210117, -210118,210120,210122,210123,210124,210125,210126,210127,210128,210130,210131,210132,210134,210136,210137, -210138,210139,210141,210142,210143,210144,210145,210146,210147,210148,210149,210150,210158,210161,210162, -210166,210167,210168,210169,210170,210171,210172,210173,210174,210175,210176,210177,210178,210179,210180, -210194,210197,210198,210199,210200,210216,210219,210223,210224,210225,210226,210692,210694,210695,210715, -210741,210742,210743,210744,210746,210778,210781,210786,210787,210788,210843,210845,210847,210848,210850, -210852,210867,210869,210895,210897,210899,210903,210904,210905,210906,210907,210908,210909,210910,210945, -210947,210948,210949,210950,210951,210952,210953,210954,210955,210956,210975,210976,210978,210979,210980, -210981,210982,210983,210984,210985,210986,210988,210990,210991,210992,210993,210994,210995,210996,210997, -210998,211000,211001,211002,211003,211004,211005,211006,211007,211008,211050,211414,211416,211418,211419, -211420,211424,211425,211427,211429,211430,211431,211432,211433,211434,211435,211436,211437,211439,211440, -211448,211450,211454,211455,211457,211460,211461,211462,211463,211502,211505,211507,211508,211511,211513, -211514,211521,211536,211543,211547,211554,211558,211563,211569,211571,211572,211588,211599,211602,211605, -211607,211608,211609,211610,211611,211612,211613,211614,211615,211616,211617,211618,211619,211620,211621, -211622,211623,211624,211625,211626,211627,211628,211629,211630,211631,211632,211634,211635,211655,211657, -211660,211664,211665,211666,211667,211668,211669,211670,211671,211672,211673,211682,211685,211689,211690, -211691,211692,211693,211694,211695,211696,211698,211699,211702,211705,211706,211719,211721,211722,211723, -211724,211725,211746,211747,211750,211754,211756,211757,211758,211759,211760,211761,211762,211763,211764, -211765,211766,211767,211768,211769,211770,211771,211772,211773,211774,211796,211798,211800,211813,211816, -211820,211821,211822,211823,211824,211825,211826,211827,211828,211840,211843,211845,211849,211850,211851, -211863,211866,211882,211900,211902,211904,211905,211906,211909,211911,211928,211930,211932,211936,211937, -211938,211939,211941,211942,211943,211944,211945,211946,211947,211950,211951,211952,211953,211954,211955, -211956,212001,212004,212005,212006,212018,212021,212022,212027,212028,212029,212030,212031,212032,212065, -212066,212068,212070,212072,212073,212074,212075,212076,212077,212083,212084,212085,212088,212090,212091, -212092,212093,212094,212096,212098,212099,212100,212120,212123,212124,212125,212126,212142,212144,212146, -212185,212188,212190,212194,212196,212197,212199,212200,212201,212202,212203,212204,212205,212206,212207, -212208,212209,212210,212219,212222,212226,212227,212228,212229,212230,212231,212232,212233,212234,212236, -212238,212249,212251,212253,212254,212255,212259,212260,212261,212262,212263,212264,212265,212267,212271, -212284,212286,212287,212289,212292,212294,212295,212296,212297,212298,212299,212300,212301,212305,212308, -212311,212312,212314,212315,212316,212317,212319,212321,212322,212325,212619,212621,212622,212624,212625, -212664,212666,212667,212668,212670,212671,212707,212709,212711,212712,212713,212714,212715,212718,212719, -212720,212721,212729,212733,212737,212738,212755,212758,212779,212782,212783,212784,212785,212847,212850, -212852,212854,212855,212856,212860,212861,212865 - ] -Crits.keepRuns.extend(list(range(212865,250000))) -#Crits.keepRuns=range(6337,10000) -# Crits.addTimeInterval([Criteria.t("1 Jun 2016"),Criteria.t("1 Jul 2016")]) -# Crits.addTimeInterval([Criteria.t("1 Oct 2016"),Criteria.t("1 Nov 2016")]) -# Crits.keepRuns=range(184000,185700) -# Crits.keepRuns.extend(range(174534 , 177133 )) -# Crits.keepRuns.extend(range(182725 , 185611)) -Crits.KeepFileRegs.append(re.compile("(.*)/Kali(.*).dst",re.I)) -# Crits.addTimeInterval([0,time.mktime(time.strptime("1 Jul 2017","%d %b %Y"))]) -# Crits.addTimeInterval([time.time()-1*86400,time.time()+3*86400]) -# Crits.keepRuns=range(193252, 193279) -# Crits.keepRuns.extend(range(193590 , 193631 )) -# Crits.keepRuns.extend(range(195416 , 195460 )) -# Crits.keepRuns.extend(range(196009 , 196087 )) -# Crits.keepRuns.extend(range(196718,196759 )) -# Crits.keepRuns.extend(range(197420, 197447 )) -# Crits.keepRuns.extend(range(198526,198506 )) - diff --git a/Online/FarmConfig/job/CaloDAQCalib.sh b/Online/FarmConfig/job/CaloDAQCalib.sh deleted file mode 100755 index d5e4889d959f3a69aced7b7f6e7910de4acf580b..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/CaloDAQCalib.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -# -. /group/calo/sw/scripts/CaloDAQCalib.sh $${DIM_DNS_NODE} ${PARTITION_NAME} ${RUN_TYPE} diff --git a/Online/FarmConfig/job/CleanAlignment.py b/Online/FarmConfig/job/CleanAlignment.py deleted file mode 100755 index bef60e5514e8da07453dcececd23410e13ee76ad..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/CleanAlignment.py +++ /dev/null @@ -1,55 +0,0 @@ -from __future__ import print_function -from builtins import str -from builtins import range -import sys -import os -import imp -import socket -import re -def selectFiles(srcdir,crits): - sfiles = os.listdir(srcdir) -# print sfiles - delfiles=[] -# print crits.exclRuns - sfiles.sort() - for i in range(len(sfiles)): - if crits.matchFile(srcdir+sfiles[i]): - delfiles.append(srcdir+sfiles[i]) - return delfiles -dontdelete=False -argu=[] -for i in range(len(sys.argv)): - if sys.argv[i].lower() == "dontdelete": - dontdelete = True - else: - argu.append(sys.argv[i]) -if len(argu) >= 3: - srcdir = argu[1] - crits = argu[2] -elif len(argu) >=2: - srcdir = argu[1] - crits = "DefaultCriteria" -else: - print("Insuffienct Number of Arguments\nUsage:\n\tCleanAlignment <srcdir> <criteria>\n") - exit(0) -mods = imp.find_module(crits) -tup=tuple(" ") -sfiles=[] -#aaaaa=imp.load_module("Crit", crits+'.py', pth,tup) -aaaaa=imp.load_module("Crit", mods[0],mods[1],mods[2]) -# aaaaa.Crits.Print() -sfiles = selectFiles(srcdir,aaaaa.Crits) -sfiles.sort() -nfiles = len(sfiles) -if dontdelete: - print(socket.gethostname()+" File Deletion disabled") -for i in range(nfiles): - if dontdelete: - print(socket.gethostname()+" selected file "+sfiles[i]) - else: - os.unlink(sfiles[i]) -# pass -if dontdelete: - print(socket.gethostname()+" No Files deleted") -else: - print(socket.gethostname()+" "+srcdir+" Total "+str(nfiles)+" files deleted") diff --git a/Online/FarmConfig/job/CondDbXfer.sh b/Online/FarmConfig/job/CondDbXfer.sh deleted file mode 100755 index 89ff4b0a3f868585d1edfef57025dcfa592b71b0..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/CondDbXfer.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -echo $1 -echo $2 -export HOME=/home/online -export USER=online # these dumb offline scripts.... -##echo "[ERROR] source /cvmfs/lhcb.cern.ch/lib/LbLogin.sh"; -source /group/online/dataflow/cmtuser/AlignmentRelease/setup.x86_64-centos7-gcc62-dbg.vars -export P1Dir=$1 -export PYTHONPATH=$P1Dir/..:$P1Dir:/group/online/hlt/conditions/git-conddb/python:/group/online/hlt/conditions/RunChangeHandler:$PYTHONPATH -unset GAUDIAPPNAME -source /sw/oracle/set_oraenv.sh -export CORAL_DBLOOKUP_PATH=/group/online/conddbserver/ -export CORAL_AUTH_PATH=/group/online/conddbserver -echo $2 -export GITCONDDBPATH=/cvmfs/lhcb.cern.ch/lib/lhcb/git-conddb -python $ALIGNONLINEROOT/python/DBXfer.py $2 -exit $? diff --git a/Online/FarmConfig/job/CondDbXfer1.sh b/Online/FarmConfig/job/CondDbXfer1.sh deleted file mode 100755 index 38ae1a622b092789407eaadb26cd6cf4a5dac4d6..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/CondDbXfer1.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -echo $1 -echo $2 -export HOME=/home/online -export USER=online # these dumb offline scripts.... -##echo "[ERROR] source /cvmfs/lhcb.cern.ch/lib/LbLogin.sh"; -source /group/online/dataflow/cmtuser/AlignmentRelease/setup.x86_64-centos7-gcc62-dbg.vars -export P1Dir=$1 -export PYTHONPATH=$P1Dir/..:$P1Dir:/group/online/hlt/conditions/git-conddb/python:/group/online/hlt/conditions/RunChangeHandler:$PYTHONPATH -unset GAUDIAPPNAME -source /sw/oracle/set_oraenv.sh -export CORAL_DBLOOKUP_PATH=/group/online/conddbserver/ -export CORAL_AUTH_PATH=/group/online/conddbserver -echo $2 -export GITCONDDBPATH=/cvmfs/lhcb.cern.ch/lib/lhcb/git-conddb -python $ALIGNONLINEROOT/python/DBXfer1.py $2 -exit $? diff --git a/Online/FarmConfig/job/CondDbXfer_doRunTick.sh b/Online/FarmConfig/job/CondDbXfer_doRunTick.sh deleted file mode 100755 index 0d50ae16a847062219f870307ecf61ea0a8c958a..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/CondDbXfer_doRunTick.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -echo $1 -echo $2 -#export HOME=/home/online -#export USER=online # these dumb offline scripts.... -#source /cvmfs/lhcb.cern.ch/lib/LbLogin.sh -source /group/online/dataflow/cmtuser/AlignmentRelease/setup.x86_64-centos7-gcc62-dbg.vars -export PYTHONPATH=$1/..:$1:/group/online/hlt/conditions/RunChangeHandler:$PYTHONPATH -#unset GAUDIAPPNAME -source /sw/oracle/set_oraenv.sh -export CORAL_DBLOOKUP_PATH=/group/online/conddbserver/ -export CORAL_AUTH_PATH=/group/online/conddbserver -python $ALIGNONLINEROOT/python/DBXfer_doRunTick.py $2 -exit $? diff --git a/Online/FarmConfig/job/ConfigureCheckpoint.py b/Online/FarmConfig/job/ConfigureCheckpoint.py deleted file mode 100755 index e8e274c8358b6a00780d099faddae667855636bb..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/ConfigureCheckpoint.py +++ /dev/null @@ -1,512 +0,0 @@ -from __future__ import print_function -from builtins import str -from builtins import object -import os, sys, imp, traceback - -global restore_args -restore_args = '' - -sep = '/' -checkpoint_zip = True -checkpoint_dir = '/group/online/dataflow/cmtuser/checkpoints' -checkpoint_expand_area = '/dev/shm/Torrents' -checkpoint_local_area = '/localdisk/checkpoints' -checkpoint_expand_area = checkpoint_local_area+'/Torrents' - -if 'LOCAL_CHECKPOINT_DIR' in os.environ: - checkpoint_local_area = os.environ['LOCAL_CHECKPOINT_DIR'] - -line = "=====================================================================================" - - -#========================================================================================= -class RunInfo(object): - """ - - \author M.Frank - \version 1.0 - """ - #======================================================================================= - def __init__(self, runinfo): - dir, fname = os.path.split(runinfo) - nam, ext = os.path.splitext(fname) - if dir not in sys.path: sys.path.insert(1,dir) - mod = imp.find_module(nam,None) - Online = imp.load_module(nam,mod[0],mod[1],mod[2]) - for i in Online.__dict__: - if i[:2] != '__': - setattr(self,i,getattr(Online,i)) - # This is sort of a hack for producing checkpoints for Brunel: - # If the brunel version cannot be obtained from the run-info, - # we simply assume the 'default' version called 'OnlineBrunel' - if not hasattr(self,'OnlineBrunelVersion'): - self.OnlineBrunelVersion = 'OnlineBrunel' - -#========================================================================================= -class Checkpoint(object): - """ - \author M.Frank - \version 1.0 - """ - - #======================================================================================= - def __init__(self, runinfo, config_task_type, config_task_family=None): - global checkpoint_local_area - self.runinfo = runinfo - self.config_task_type = config_task_type - self.config_task_family = config_task_family - ##print 'echo "[INFO] '+str(isinstance(self.config_task_type,str))+'";' - if isinstance(self.config_task_type,str): - self.task_type = self.config_task_type - elif self.config_task_type: - self.task_type = 'OnlineBrunel' # FixME: runinfo.HLTType - elif runinfo.MooreOnlineVersion == "" or runinfo.MooreOnlineVersion == "DEFAULT": - self.task_type = 'PassThrough' - else: - self.task_type = 'Moore1' # FixME: runinfo.HLTType - - self.cmtConfig = 'x86_64-centos7-gcc62-dbg' - if 'CHECKPOINTING_CONFIG' in os.environ: - self.cmtConfig = os.environ['CHECKPOINTING_CONFIG'] - elif 'CMTCONFIG' in os.environ: - self.cmtConfig = os.environ['CMTCONFIG'] - self.torrent_file = self._getTorrentFile() - self.checkpoint_bin = os.environ['CHECKPOINTING_BIN'] - self.restore = 'restore.exe' ##self.checkpoint_bin + '/bin/restore.exe' - if self.torrent_file: - if checkpoint_zip: - self.target_path = checkpoint_expand_area+sep+self.task_type+sep+"Checkpoint.data" - else: - self.target_path = checkpoint_local_area+self.checkpointRelativeDir()+sep+self.torrent_file - self.lib_dir = os.path.dirname(self.target_path)+'/lib' - - #======================================================================================= - def _getTorrentFile(self): - try: - if (self.config_task_family=='REC' and self.runinfo.RecoStartupMode > 1): - directory = checkpoint_dir + self.checkpointRelativeDir() - for i in os.listdir(directory): - idx=i.find('.data') - if idx>0 and idx==len(i)-5: - return i - elif (self.config_task_family=='HLT' and self.runinfo.MooreStartupMode > 1): - directory = checkpoint_dir + self.checkpointRelativeDir() - for i in os.listdir(directory): - idx=i.find('.data') - if idx>0 and idx==len(i)-5: - return i - except Exception as X: - print('echo "[ERROR] Check torrent file: '+str(X)+'";') - return None - - #======================================================================================= - def checkpointRelativeDir(self): - ri = self.runinfo - if self.config_task_family == 'REC' and self.config_task_type: - Mapping = os.path.basename(ri.ConditionsMapping) - checkpoint_reloc = sep+self.task_type+sep+ri.OnlineBrunelVersion+sep+\ - ri.CondDBTag+sep+ri.DDDBTag+sep+Mapping - elif ri.MooreOnlineVersion == "" or ri.MooreOnlineVersion == "DEFAULT": - checkpoint_reloc = sep+ri.HltArchitecture+sep+ri.OnlineVersion+sep+ri.HLTType - else: - Mapping = os.path.basename(ri.ConditionsMapping) - checkpoint_reloc = sep+'Moore'+sep+ri.MooreOnlineVersion+sep+\ - ri.HLTType+sep+ri.CondDBTag+sep+ri.DDDBTag+sep+\ - Mapping+sep+self.task_type - checkpoint_reloc = checkpoint_reloc + sep + self.cmtConfig - return checkpoint_reloc - - #======================================================================================= - def torrentFile(self): - return self.torrent_file - - #======================================================================================= - def output(self, message): - print(message) - ## print 'echo [INFO] ',message - return self - - #======================================================================================= - def initProcess(self): - self.output('unset CHECKPOINT_DIR;') \ - .output('unset CHECKPOINT_FILE;') \ - .output('unset LD_PRELOAD;') \ - .output('export CHECKPOINTING_BIN='+self.checkpoint_bin+';') \ - .output('export CHECKPOINTING_CONFIG='+self.cmtConfig+';') - - if self.config_task_family=='REC': - self.output('export PYTHONPATH=/group/online/dataflow/options/'+self.runinfo.PartitionName+'/RECONSTRUCTION:${PYTHONPATH};') - elif self.config_task_family=='DQ': - self.output('export PYTHONPATH=/group/online/dataflow/options/'+self.runinfo.PartitionName+':${PYTHONPATH};') - elif self.runinfo.PartitionName=='LHCb2': - self.output('export PYTHONPATH=/group/online/dataflow/options/'+self.runinfo.PartitionName+'/HLT:${PYTHONPATH};') - else: - self.output('export PYTHONPATH=/run/options/'+self.runinfo.PartitionName+':/group/online/dataflow/options/'+self.runinfo.PartitionName+'/HLT:${PYTHONPATH};') - ##self.output('export PYTHONPATH=/group/online/dataflow/options/'+self.runinfo.PartitionName+'/HLT:${PYTHONPATH};') - return self - - #======================================================================================= - def addSlaves(self): - return self.output('export NUM_CORES=${NBOFSLAVES};') - - #======================================================================================= - def preload(self): - return self.output('export LD_PRELOAD=libCheckpointing.so;') - - #======================================================================================= - def setupNormal(self): - return self.initProcess().output('export APP_STARTUP_OPTS=-normal;').preload() \ - .output('export CHECKPOINT_SETUP_OPTIONS=${FARMCONFIGROOT}/options/Empty.opts;') - - #======================================================================================= - def setupForking(self): - return self.initProcess().addSlaves().preload() \ - .output('export APP_STARTUP_OPTS=-forking;') - - #======================================================================================= - def setupCheckpointFile(self): - #self.output('export CHECKPOINT_DIR='+os.path.dirname(self.target_path)+';') \ - # .output('export CHECKPOINT_FILE='+self.target_path+';') - self.output('export CHECKPOINT_SETUP_OPTIONS=${FARMCONFIGROOT}/options/Checkpoint.opts;') \ - .output('export CHECKPOINT_RESTART_OPTIONS=${FARMCONFIGROOT}/options/CheckpointRestart.opts;') - return self - - #======================================================================================= - def extractLibs(self): - """ - Note: - There is quite some optimization here by checking the modifcation date - of the libs directory against the modification date of the checkpoint file. - """ - lib_md5 = self.target_path+'.libs.md5' - tar_md5 = checkpoint_dir + self.checkpointRelativeDir()+os.sep+self.torrent_file+'.libs.md5' - self.output('if test ! -d "'+self.lib_dir+'"; then') \ - .output(' need_extract=1;')\ - .output('elif test ! -f "'+lib_md5+'"; then') \ - .output(' need_extract=1;')\ - .output('elif test -d "'+self.lib_dir+'"; then') - #self.output(' echo md5sum '+tar_md5+';')\ - # .output(' echo md5sum '+lib_md5+';') - self.output(' torrent_stat=`md5sum '+tar_md5+' | cut -b 1-32`;')\ - .output(' libsdir_stat=`md5sum '+lib_md5+' | cut -b 1-32`;')\ - .output(' if test "${libsdir_stat}" != "${torrent_stat}"; then')\ - .output(' need_extract=1;')\ - .output(' fi;') \ - .output('fi;') - - self.output('if test -n "${need_extract}"; then')\ - .output(' echo "[INFO] Need to expand libraries from checkpoint before start [Check-sum].";') \ - .output(' mkdir -p '+self.lib_dir+';') \ - .output(' rm -f '+self.lib_dir+'/*;') \ - .output( self.restore + ' -p 4 -x -C -i '+self.target_path+' -l '+self.lib_dir+'/;') \ - .output(' cd '+self.lib_dir+'; md5sum `ls -S -1 . | grep -v passwd` > '+lib_md5+'; cd -;') \ - .output('else') \ - .output(' echo "[INFO] MD5 of libs[${libsdir_stat}] fits torrent[${torrent_stat}] Nothing to expand before start [Checksum-OK].";') \ - .output('fi;') - - self.output('if test ! -d "'+self.lib_dir+'"; then') \ - .output(' echo "[FATAL] '+line+'";') \ - .output(' echo "[FATAL] == CHECKPOINT LIBS DIRECTORY '+self.lib_dir+' DOES NOT EXIST!";') \ - .output(' echo "[FATAL] '+line+'";') \ - .output(' exit 1;') \ - .output('fi;') - self.output('if test ! -f "'+lib_md5+'"; then') \ - .output(' echo "[FATAL] '+line+'";') \ - .output(' echo "[FATAL] == CHECKPOINT LIBS MD5 '+lib_md5+' DOES NOT EXIST!";') \ - .output(' echo "[FATAL] '+line+'";') \ - .output(' exit 1;') \ - .output('fi;') - return self - - #======================================================================================= - def extractLibs_old(self): - """ - Note: - There is quite some optimization here by checking the modifcation date - of the libs directory against the modification date of the checkpoint file. - """ - self.output('if test ! -d "'+self.lib_dir+'"; then') \ - .output(' need_extract=1;')\ - .output('fi;') - self.output('if test -d "'+self.lib_dir+'"; then') \ - .output(' torrent_stat=`stat -c "%Y" '+self.target_path+'`;')\ - .output(' libsdir_stat=`stat -c "%Y" '+self.lib_dir+'`;')\ - .output(' if test ${libsdir_stat} -le ${torrent_stat};then')\ - .output(' need_extract=1;')\ - .output(' fi;') \ - .output('fi;') - - self.output('if test -n "${need_extract}"; then')\ - .output(' echo "[INFO] Need to expand libraries from checkpoint before start [Time-stams].";') \ - .output( self.restore + ' -p 4 -x -C -i '+self.target_path+' -l '+self.lib_dir+'/;') \ - .output('else') \ - .output(' echo "[INFO] lib[${libsdir_stat}] is younger than torrent[${torrent_stat}] Nothing to expand before start [Time-stamps-OK].";') \ - .output('fi;') - - self.output('if test ! -d "'+self.lib_dir+'"; then') \ - .output(' echo "[FATAL] '+line+'";') \ - .output(' echo "[FATAL] == CHECKPOINT LIBS DIRECTORY '+self.lib_dir+' DOES NOT EXIST!";') \ - .output(' echo "[FATAL] '+line+'";') \ - .output(' exit 1;') \ - .output('fi;') - return self - - #======================================================================================= - def setupRestoreEnv(self): - return self.initProcess().addSlaves() \ - .output('export APP_STARTUP_OPTS=-restore;') - - #======================================================================================= - def setupRestore(self, extract=True): - ldir = self.checkpointRelativeDir() - relocate_path = ldir+sep+self.torrent_file - if extract: extract_libs_opt = '-x' - else: extract_libs_opt = '-X' - local_libs_opt = ' -l '+self.lib_dir - - restore_cmd = 'exec -a ${UTGID} '+self.restore+' -p 4 -e '+\ - extract_libs_opt+local_libs_opt+' -i '+self.target_path - - print('echo "[INFO] Checkpointing Restore from torrent: '+restore_cmd+'";') - self.initProcess().setupCheckpointFile() \ - .output('echo "[DEBUG] Setup restore process for %s";'%(self.task_type,)) \ - .output('export APP_STARTUP_OPTS=-restore;') \ - .output('sleep 3;') \ - .output('RESTORE_CMD="'+restore_cmd+'";') \ - .output('if test ! -f "'+self.target_path+'"; then') \ - .output(' echo "[FATAL] '+line+'";') \ - .output(' echo "[FATAL] == CHECKPOINT FILE '+self.target_path+' DOES NOT EXIST!";') \ - .output(' echo "[FATAL] '+line+'";') \ - .output(' exit 1;') \ - .output('fi;') - return self.addSlaves() # Normal running - - #======================================================================================= - def copyTorrent(self): - ldir = self.checkpointRelativeDir() - relocate_path = self.checkpointRelativeDir()+sep+self.torrent_file - expand_path = self.target_path - self.setupCheckpointFile() \ - .output('echo "[INFO] Copy checkpoint:'+relocate_path+'";') - if self.config_task_family=='REC': - self.output('bash '+checkpoint_dir+'/cmds/copy_data '+relocate_path+' '+self.task_type+';') - else: - self.output('bash '+checkpoint_dir+'/cmds/copy_torrent.zipped '+relocate_path+' '+self.task_type+';') - self.output('if test ! -f "'+self.target_path+'"; then') \ - .output(' echo "[FATAL] '+line+'";') \ - .output(' echo "[FATAL] == CHECKPOINT FILE '+self.target_path+' DOES NOT EXIST!";') \ - .output(' echo "[FATAL] '+line+'";') \ - .output(' exit 1;') \ - .output('fi;') - return self - -#========================================================================================= -def torrent_restore(cp, extract=True): - torrent_file = cp.torrentFile() - if torrent_file: - return cp.setupRestore(extract) - print('echo "[ERROR] Checkpointing '+cp.checkpointRelativeDir()+' requested, but no checkpoint present.";') - print('exit 1;') - return None - -#========================================================================================= -def torrent_copy(cp,copy,extract): - torrent_file = cp.torrentFile() - if torrent_file: - res=None - if copy: res = cp.copyTorrent() - if (res and copy and extract) or extract: res = cp.extractLibs() - if res: return 1 - print('echo "[ERROR] Checkpointing '+cp.checkpointRelativeDir()+' requested, but no checkpoint present.";') - print('exit 1;') - return None - -#========================================================================================= -def setupEnviron(runinfo, config_task_family, config_task_type): - ri = RunInfo(runinfo) - ##print 'echo "[ERROR] Configure CHECKPOINT environment. Reco:%s/%d Moore:%d";'%(str(config_task_type),ri.RecoStartupMode,ri.MooreStartupMode,) - cp = Checkpoint(ri,config_task_type,config_task_family) - - if config_task_family=='REC' and ri.RecoStartupMode == 0: - return cp.setupNormal() - elif config_task_family=='REC' and ri.RecoStartupMode == 1: - return cp.setupForking() - elif config_task_family=='REC' and ri.RecoStartupMode == 2: - return cp.setupRestoreEnv() - elif ri.MooreStartupMode == 0: - return cp.setupNormal() - elif ri.MooreStartupMode == 1: - return cp.setupForking() - elif ri.MooreStartupMode == 2: - return cp.setupRestoreEnv() - else: - print('echo "[ERROR] Undefined CHECKPOINT startup mode in runinfo. Exiting";') - print('exit 1;') - return None - -#========================================================================================= -def configureForRunning(runinfo, config_task_family, config_task_type, extract=True): - ri = RunInfo(runinfo) - ##print 'echo "[ERROR] Configure CHECKPOINT for running. Reco:%s/%d Moore:%d";'%(str(config_task_type),ri.RecoStartupMode,ri.MooreStartupMode,) - cp = Checkpoint(ri,config_task_type,config_task_family) - - if config_task_family=='REC' and ri.RecoStartupMode == 0: - return cp.setupNormal() - elif config_task_family=='REC' and ri.RecoStartupMode == 1: - return cp.setupForking() - elif config_task_family=='REC' and ri.RecoStartupMode == 2: - return torrent_restore(cp, extract) - elif ri.MooreStartupMode == 0: - return cp.setupNormal() - elif ri.MooreStartupMode == 1: - return cp.setupForking() - elif ri.MooreStartupMode == 2: - return torrent_restore(cp, extract) - else: - print('echo "[ERROR] Undefined CHECKPOINT startup mode in runinfo. Exiting";') - print('exit 1;') - return None - -#========================================================================================= -def extractLibraries(runinfo,copy,extract,config_task_family,config_task_type): - ri = RunInfo(runinfo) - cp = Checkpoint(ri,config_task_type,config_task_family) - if config_task_family=='REC' and (ri.RecoStartupMode == 0 or ri.RecoStartupMode == 1): - print('echo "[DEBUG] No checkpoints to be manipulated for BRUNEL startup mode:'+str(ri.RecoStartupMode)+'.";') - return 1 - elif config_task_family=='REC' and ri.RecoStartupMode == 2: - return torrent_copy(cp,copy,extract) - elif ri.MooreStartupMode == 0 or ri.MooreStartupMode == 1: - #print 'echo "[DEBUG] No checkpoints to be manipulated for MOORE startup mode:'+str(ri.MooreStartupMode)+'.";' - return 1 - elif ri.MooreStartupMode == 2: - return torrent_copy(cp,copy,extract) - else: - print('echo "[ERROR] Undefined MOORE startup mode in runinfo. Exiting";') - print('exit 1;') - return None - -#========================================================================================= -def configureForCheckpoint(runinfo): - print('export APP_STARTUP_OPTS="-checkpoint -auto";') - chkpt_dir = os.path.dirname(os.path.dirname(os.environ['CHECKPOINTINGROOT'])) - print('export CHECKPOINTING_BIN='+chkpt_dir+'/InstallArea/'+os.environ['CMTCONFIG']+';') - print('export CHECKPOINT_DIR; export CHECKPOINT_FILE;') - print('export PYTHONPATH=${CHECKPOINT_DIR}:${PYTHONPATH};') - print('export MBM_SETUP_OPTIONS='+checkpoint_dir+'/cmds/MBM_setup.opts;') - print('export CHECKPOINT_SETUP_OPTIONS='+checkpoint_dir+'/cmds/Checkpoint.opts;') - print('echo "[INFO] '+line+'";') - print('echo "[INFO] == Running in checkkpoint PRODUCTION mode....";') - print('echo "[INFO] == File: ${CHECKPOINT_FILE} MBM setup:${MBM_SETUP_OPTIONS}";') - print('echo "[INFO] == Producing CHECKPOINT file......Please be patient. RunInfo:'+runinfo+'";') - print('echo "[INFO] == LD_PRELOAD=libCheckpointing.so";') - print('echo "[INFO] '+line+'";') - # Note: This is the VERY LAST statement. Afterwards the executable MUST run! - print('export LD_PRELOAD=libCheckpointing.so;') - -#========================================================================================= -def configureForTest(runinfo): - print('echo "[ALWAYS] Running in checkpoint TESTING mode....";') - print('export APP_STARTUP_OPTS=-restore;') - print('export CHECKPOINT_DIR; export CHECKPOINT_FILE;') - print('export PYTHONPATH=${CHECKPOINT_DIR}:${PYTHONPATH};') - print('export CHECKPOINT_EXPANSION_DIR=/dev/shm/checkpoint;') - print('export CHECKPOINT_EXPANSION_DIR=/localdisk/checkpoints/test;') - print('rm -rf ${CHECKPOINT_EXPANSION_DIR}/*;') - print('mkdir -p ${CHECKPOINT_EXPANSION_DIR};') - print('RESTORE_CMD="exec -a ${UTGID} restore.exe -p 4 -e -l ${CHECKPOINT_EXPANSION_DIR} -i ${CHECKPOINT_FILE}";') - print('echo "[ALWAYS] '+line+'";') - print('echo "[ALWAYS] == File: ${CHECKPOINT_FILE} MBM setup:${MBM_SETUP_OPTIONS}";') - print('echo "[ALWAYS] == Command ${RESTORE_CMD}";') - print('echo "[ALWAYS] == Testing CHECKPOINT file......Please be patient. RunInfo:'+runinfo+'";') - print('echo "[ALWAYS] == DO NOT CLOSE THE PANEL YET UNLESS CHECKPOINT TEST IS OVER !!!!!";') - print('echo "[ALWAYS] '+line+'";') - print('if test ! -f "${CHECKPOINT_FILE}";then') - print(' echo "[FATAL] '+line+'";') - print(' echo "[FATAL] == CHECKPOINT FILE ${CHECKPOINT_FILE} DOES NOT EXIST!";') - print(' echo "[FATAL] '+line+'";') - print(' exit 2;') - print('fi;') - print('echo "[ALWAYS] '+line+'";') - print('echo "[ALWAYS] == Executing second restore to extract libraries and computing lib checksum. RunInfo:'+runinfo+'";') - print('echo "[ALWAYS] == DO NOT CLOSE THE PANEL YET UNLESS CHECKPOINT TEST IS OVER !!!!!";') - print('echo "[ALWAYS] '+line+'";') - print('restore.exe -p 4 -x -C -l ${CHECKPOINT_EXPANSION_DIR} -i ${CHECKPOINT_FILE};') - print('CURR=`pwd`;cd ${CHECKPOINT_EXPANSION_DIR}; md5sum `ls -S . | grep -v passwd` > ${CHECKPOINT_FILE}.libs.md5; cd ${CURR};') - print('if test ! -f "${CHECKPOINT_FILE}.libs.md5";then') - print(' echo "[FATAL] '+line+'";') - print(' echo "[FATAL] == CHECKPOINT library checksum FILE ${CHECKPOINT_FILE}.libs.md5 DOES NOT EXIST!";') - print(' echo "[FATAL] '+line+'";') - print(' exit 2;') - print('fi;') - -#========================================================================================= -def doIt(): - import optparse - parser = optparse.OptionParser() - parser.description = 'Helper to start and configure checkpointing actions' - parser.add_option("-r","--runinfo",dest='runinfo',default=None, - help="Set RunInfo file name",metavar="<FILE>") - parser.add_option("-c","--copy",dest='copy',default=False,action='store_true', - help="Flag to copy checkpoint to target",metavar="<boolean>") - parser.add_option("-e","--environ",dest='environ',default=False,action='store_true', - help="Setup environment from run info",metavar="<boolean>") - parser.add_option("-l","--libs",dest='libs',default=False,action='store_true', - help="Extract libraries from existing checkpoint file",metavar="<directory>") - parser.add_option("-x","--test",dest='test',default=False,action='store_true', - help="Test existing checkpoint file",metavar="<boolean>") - parser.add_option("-f","--create",dest='create',default=False,action='store_true', - help="Create checkpoint file checkpoint file",metavar="<boolean>") - parser.add_option("-s","--start",dest='start',default=False,action='store_true', - help="Start process according to runinfo",metavar="<boolean>") - parser.add_option("-b","--brunel",dest='brunel',default=False,action='store_true', - help="Configure checkpointing for brunel",metavar="<boolean>") - parser.add_option("-t","--task_type",dest='task_type',default=None, - help="Set special task type for brunel configuration",metavar="<string>") - - try: - (opts, args) = parser.parse_args() - - ##print 'echo [ERROR] Flags: ',opts.copy,opts.libs,opts.test,opts.create,';' - if 'TEST_CHECKPOINT' in os.environ or opts.test: - configureForTest(opts.runinfo) - return - elif 'CREATE_CHECKPOINT' in os.environ or opts.create: - configureForCheckpoint(opts.runinfo) - return - elif opts.runinfo is None: - parser.format_help() - return - - task_family = 'HLT' - config_task_type = 'Moore1' - if opts.brunel and not opts.task_type: - config_task_type = 'OnlineBrunel' - task_family = 'REC' - elif opts.brunel and opts.task_type: - config_task_type = opts.task_type - task_family = 'REC' - elif opts.task_type: - config_task_type = opts.task_type - else: - config_task_type = 'Moore1' - - if opts.environ: - setupEnviron(opts.runinfo,config_task_family=task_family,config_task_type=config_task_type) - if opts.copy and opts.libs: - extractLibraries(opts.runinfo,copy=True,extract=True,config_task_family=task_family,config_task_type=config_task_type) - elif opts.copy: - extractLibraries(opts.runinfo,copy=True,extract=False,config_task_family=task_family,config_task_type=config_task_type) - elif opts.libs: - extractLibraries(opts.runinfo,copy=False,extract=True,config_task_family=task_family,config_task_type=config_task_type) - if opts.start: - configureForRunning(opts.runinfo,config_task_family=task_family,config_task_type=config_task_type,extract=opts.libs) - print('if [ -e ${FARMCONFIGROOT}/job/FixPythonPath.py ] ;then eval `python ${FARMCONFIGROOT}/job/FixPythonPath.py`; fi') - except Exception as X: - traceback.print_stack() - print('echo "[ERROR] Exception(ConfigureCheckpoint): Checkpoint production mode:'+str(X)+'";') - print('exit 1;') - -#========================================================================================= -if __name__ == '__main__': - doIt() diff --git a/Online/FarmConfig/job/ConfigureFromCheckpoint.py b/Online/FarmConfig/job/ConfigureFromCheckpoint.py deleted file mode 100755 index 156aa0f5547d0c47470dfa4a41bce18d2f86a358..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/ConfigureFromCheckpoint.py +++ /dev/null @@ -1,18 +0,0 @@ -from __future__ import print_function -import os, sys -if 'PARTITION_NAME' in os.environ: - pname = os.environ['PARTITION_NAME'] -else: - pname = os.environ['PARTITION'] -print('UTGID='+os.environ['UTGID']+';') -print("DIM_DNS_NODE="+os.environ['DIM_DNS_NODE']+';') -print("NUMBER_OF_CHILDREN="+os.environ['NBOFSLAVES']+';') -if 'TEST_CHECKPOINT' in os.environ: - print('TEST_CHECKPOINT='+os.environ['TEST_CHECKPOINT']+';') - print('PARTITIONOPTS='+os.environ['CHECKPOINT_DIR']+'/OnlineEnv.opts;') -else: - print('PARTITIONOPTS=/group/online/dataflow/options/'+pname+'/'+pname+'_Info.opts;') - if 'CHECKPOINT_SETUP_OPTIONS' in os.environ: - print("CHECKPOINT_SETUP_OPTIONS="+os.environ['CHECKPOINT_SETUP_OPTIONS']+';') - if 'CHECKPOINT_RESTART_OPTIONS' in os.environ: - print("RESTARTOPTS="+os.environ['CHECKPOINT_RESTART_OPTIONS']+';') diff --git a/Online/FarmConfig/job/Controller.old.sh b/Online/FarmConfig/job/Controller.old.sh deleted file mode 100644 index bd150c91c2b8ac7f7ca2cdffd46add678c9ff274..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/Controller.old.sh +++ /dev/null @@ -1,132 +0,0 @@ -#!/bin/bash -# ========================================================================= -# -# Farm worker node controller startup script -# -# Author M.Frank -# Version: 1.0 -# Date: 20/05/2013 -# -# ========================================================================= -# -# Output: -print=${OUTPUT_LEVEL} \ -# Debug: -sleep=20 \ -# -# -STRACE_CMD=; -HH=`hostname -s | tr a-z A-Z`; -if test "${MOORESTARTUP_MODE}" = "RESTORE"; -then - mkdir -p /tmp/Commands; # Needed by the tasks - if test "${HH}" = "`echo ${HH} | grep -i -e hlt[a-f][0-1][0-9][0-3][0-9]`"; then - CFG=${CMTCONFIG}; - export CMTCONFIG=x86_64-centos7-gcc62-opt; - export CHECKPOINTING_CONFIG=${CMTCONFIG}; - if test "${PARTITION_NAME}" = "LHCb"; then - ##echo `python ${FARMCONFIGROOT}/job/ConfigureCheckpoint.py -r ${RUNINFO} -c -l` | tr ";" ";\n"; - eval `python ${FARMCONFIGROOT}/job/ConfigureCheckpoint.py -r ${RUNINFO} -c -l`; - elif test "${PARTITION_NAME}" = "LHCb2"; then - eval `python ${FARMCONFIGROOT}/job/ConfigureCheckpoint.py -r ${RUNINFO} -c -l -t Moore2`; - elif test "${PARTITION_NAME}" = "FEST"; then - eval `python ${FARMCONFIGROOT}/job/ConfigureCheckpoint.py -r ${RUNINFO} -c -l`; - fi; - export CMTCONFIG=${CFG}; - fi; -fi; -# -# Only copy options on worker nodes locally! and not on the main HLT node nor the calibration farm -if test "${HH}" != "${SUBFARM}"; then - if test "${SUBFARM}" = "CALD07"; then - echo "Controller: Nothing to do: No job options shall be copied locally"; - elif test "${SUBFARM}" = "MONA10"; then - echo "Controller: Nothing to do: No job options shall be copied locally"; - else - OPT_DIR=/run/options/${PARTITION_NAME}/; - OPT_SRC=/group/online/dataflow/options/${PARTITION_NAME}; - rm -rf /run/options/${PARTITION_NAME}/*; - mkdir -p ${OPT_DIR}; - cp ${OPT_SRC}/HLT/OnlineEnv.py ${OPT_DIR}; - cp ${OPT_SRC}/HLT/OnlineEnvBase.py ${OPT_DIR}; - cp ${OPT_SRC}/HLT/${PARTITION_NAME}_Info.py ${OPT_DIR}; - ##cp ${OPT_SRC}/HLT/${PARTITION_NAME}_Tell1Boards.py ${OPT_DIR}; - cp ${OPT_SRC}/HLT/${PARTITION_NAME}_`echo ${DIM_DNS_NODE} | tr a-z A-Z`_HLT.py ${OPT_DIR}; - cp ${OPT_SRC}/${PARTITION_NAME}_`echo ${DIM_DNS_NODE} | tr a-z A-Z`_HLT.opts ${OPT_DIR}; - cp ${OPT_SRC}/${PARTITION_NAME}_Info.opts ${OPT_DIR}; - if test "${PARTITION_NAME}" = "LHCbA"; then - echo None > /dev/null; - elif test "${PARTITION_NAME}" = "LHCb1"; then - cp ${OPT_SRC}/HLT/MBM_setup.opts ${OPT_DIR}; - elif test "${PARTITION_NAME}" = "LHCb2"; then - cp ${OPT_SRC}/HLT/MBM_setup.opts ${OPT_DIR}; - cp ${OPT_SRC}/Nodes/${HH}_TriggerInfo.opts ${OPT_DIR}; - cp ${OPT_SRC}/Nodes/${HH}_TriggerInfo.py ${OPT_DIR}; - else - cp ${OPT_SRC}/HLT/MBM_setup.opts ${OPT_DIR}; - cp ${OPT_SRC}/${PARTITION_NAME}_Tell1Boards.opts ${OPT_DIR}; - fi; - fi; -else - OPT_DIR=/run/options/${PARTITION_NAME}/; - OPT_SRC=/group/online/dataflow/options/${PARTITION_NAME}; - rm -rf /run/options/${PARTITION_NAME}/*; - mkdir -p ${OPT_DIR}; - cp ${OPT_SRC}/HLT/OnlineEnv.py ${OPT_DIR}; - cp ${OPT_SRC}/HLT/OnlineEnvBase.py ${OPT_DIR}; - cp ${OPT_SRC}/HLT/${PARTITION_NAME}_Info.py ${OPT_DIR}; - cp ${OPT_SRC}/${PARTITION_NAME}_Info.opts ${OPT_DIR}; -fi; -# -# -ctrl_args="-count=${NBOFSLAVES} -bindcpu=0"; -PRINT_LEVEL=4; -# -# ================================================================================ -# Special handling of DataQuality -# ================================================================================ -if test "${PARTITION_NAME}" = "DQ"; then - PRINT_LEVEL=4; -fi; -# ================================================================================ -# Special handling of LHCb -# ================================================================================ -if test "${PARTITION_NAME}" = "LHCb"; then - PRINT_LEVEL=4; - ctrl_args="-count=${NBOFSLAVES} -bindcpu=2 -service=${UTGID}/NTasks" -fi; -# ================================================================================ -# Special handling of LHCb2 -# ================================================================================ -if test "${PARTITION_NAME}" = "LHCb2"; then - PRINT_LEVEL=3; - #PRINT_LEVEL=4; - # This will make the controller wait until on PAUSE all slaves are paused. - #ctrl_args="-fsm=DAQPause"; - ctrl_args="-count=${NBOFSLAVES} -bindcpu=2 -service=${UTGID}/NTasks" - echo "[INFO] ${UTGID} Partition:${PARTITION_NAME} Arguments: ${ctrl_args} Print-Level:${PRINT_LEVEL}"; - #if test "${HH}" = "HLTA0215"; then - #ctrl_args="-count=22 -bindcpu=0"; - #ctrl_args="-sleep=200 ${ctrl_args}"; - #fi; -fi; -if test "${HH}" = "HLTC0417"; then - if test "${PARTITION_NAME}" = "LHCb"; then - ctrl_args="-count=${NBOFSLAVES} -bindcpu=1 -service=${UTGID}/NTasks" -# cd /home/frankm/cmtuser/OnlineDev_v5r24; -# . setup.x86_64-centos7-gcc48-dbg.vars; -# ls -laF /proc/$$/fd > /tmp/fd.log -# STRACE_CMD="strace -o /tmp/ctrl.trace"; -# #PRINT_LEVEL=2; - echo "[DEBUG] ${UTGID} `pwd`"; - fi; -fi; -# -# -# -exec -a ${UTGID} ${STRACE_CMD} fsm_ctrl.exe \ - -print=${PRINT_LEVEL} \ - -partition=${PARTITION_NAME} \ - -runinfo=${RUNINFO} \ - -mode=${MOORESTARTUP_MODE} \ - -taskconfig=${ARCH_FILE} \ - -maxcount=50 \ - ${ctrl_args} diff --git a/Online/FarmConfig/job/CopyDellFiles.py b/Online/FarmConfig/job/CopyDellFiles.py deleted file mode 100755 index 01fa2e8f4be37ccd8beb42dc005f28425a5b8a27..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/CopyDellFiles.py +++ /dev/null @@ -1,49 +0,0 @@ -from __future__ import print_function -from builtins import str -from builtins import range -import sys -import os -import re -import socket -def selectFiles(srcdir): - try: - sfiles = os.listdir(srcdir) - except: - sfiles=[] - return sfiles -Manufacturer=os.getenv("Manufacturer", "") -if (Manufacturer.find("Dell") == -1) and (Manufacturer.find("Inventec")) == -1: - print("Not a DELL Node. Exiting...") - exit(0) -if len(sys.argv) >= 2: -# srcdir = sys.argv[1] - destbase = sys.argv[1] -else: - print("Insufficient Number of Arguments\nUsage:\n\tCopyDellFiles <destbaseNr>\n") - exit(0) -MyName = socket.gethostname() -MyNodeNr = int(MyName[6:8])-1 -MyFarm = MyName[0:6] -DestNodeNr = int(destbase) +(MyNodeNr % 4) -DestNode = MyFarm+str(DestNodeNr) -cfname = "/tmp/"+DestNode+".sh" -f = open(cfname,"w") -f.write("#!/bin/bash\n") -srcdir=["/localdisk1/hlt1","/localdisk2/hlt1"] -for dsk in range(len(srcdir)): - destdev = os.path.split(srcdir[dsk])[0] - destdir = 'hlt_COPY' - sfiles = selectFiles(srcdir[dsk]) - sfiles.sort() - nfiles = len(sfiles) - nmap = dict() - print("Number of files in directory "+str(nfiles)) - for j in range(len(sfiles)): -# f.write("scp -l 350000 "+srcdir[dsk]+"/"+sfiles[j]+" online@"+DestNode+":"+destdev+"/"+destdir+"\n") - f.write("scp "+srcdir[dsk]+"/"+sfiles[j]+" online@"+DestNode+":"+destdev+"/"+destdir+"\n") -f.close() -cmd = "chmod 777 "+cfname -os.system(cmd) -cmd = cfname+" &" -print("excuting "+cmd+"\n") -os.system(cmd) diff --git a/Online/FarmConfig/job/CopyRuns.py b/Online/FarmConfig/job/CopyRuns.py deleted file mode 100755 index 47b00b4bac50e65afb5ddfe6e7caeb67045b13f8..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/CopyRuns.py +++ /dev/null @@ -1,66 +0,0 @@ -from __future__ import print_function -from builtins import range -import sys -import os -import re -import socket -def listFiles(srcdir): - sfiles=[] - for sd in srcdir: -# print sd - try: - fils = os.listdir(sd) - except: - fils=[] - for i in range(len(fils)): - fils[i] = sd+"/"+fils[i] - sfiles+=fils - return sfiles - -rrange = list(range(0)) -drange = list(range(0)) -def selectFiles(files,runrange): - selfil=[] -# print runrange - for f in files: - a=f.split('_') - if a[0].find('/Run') != -1: - if int(a[1]) in runrange: - selfil.append(f) - return selfil -if len(sys.argv) >= 2: -# srcdir = sys.argv[1] - runrange = sys.argv[1] -else: - print("Insufficient Number of Arguments\nUsage:\n\tCopyRuns <RunRange> \n") - exit(0) -MyName = socket.gethostname() -# MyNodeNr = int(MyName[6:8])-1 -# MyFarm = MyName[0:6] -# DestNodeNr = int(destbase) +(MyNodeNr % 4) -# DestNode = MyFarm+str(DestNodeNr) -r = runrange.split("-") -if len(r)>1: - rrange=list(range(int(r[0]),int(r[1])+1)) -else: - if runrange.find('-') == -1: - rrange=list(range(int(r[0]),999999)) - else: - rrange=list(range(int(r[0]),int(r[0])+1)) - -srcdir=["/localdisk1/hlt1","/localdisk2/hlt1"] -files=[] -files=listFiles(srcdir) -fils=selectFiles(files,rrange) -cfname = "/tmp/RunCopy-"+runrange+".sh" -fil=open(cfname,"w") -fil.write("#!/bin/bash\n") -for f in fils: - dest = f.replace('hlt1','hlt1_KEEP') - fil.write("cp "+f+" "+dest+"\n") -fil.close() -cmd = "chmod 777 "+cfname -os.system(cmd) -cmd = cfname#+" &" -print(MyName+": executing "+cmd+"\n") -os.system(cmd) diff --git a/Online/FarmConfig/job/Criteria.py b/Online/FarmConfig/job/Criteria.py deleted file mode 100755 index a444f1d71c0fb31c5bb12ebb66ed68591fc8064f..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/Criteria.py +++ /dev/null @@ -1,67 +0,0 @@ -from __future__ import print_function -from builtins import object -import sys -import os -import imp -import time -import re -class Criteria(object): - def Criteria(self): - pass - def __init__(self): - self.keepRuns = set() - self.deleteRuns=set() - self.DelFileRegs = [] - self.DelFileRegs.append(re.compile("(.*)/Run_(.*)", re.I)) - self.KeepFileRegs = [] -# self.KeepFileRegs.append(re.compile("(.*)/Kali_(.*)", re.I)) -# self.timBefore = 0xffffffff -# self.timAfter = 0 - self.timeIntervals = [[0xffffffff,0]] - def setBeforeTime(self,tval): - self.timBefore = time.mktime(time.strptime(tval,"%d %b %Y")) - def setAfterTime(self,tval): - self.timAfter= time.mktime(time.strptime(tval,"%d %b %Y")) - def addTimeInterval(self,intv): - if [0xffffffff,0] in self.timeIntervals: - self.timeIntervals.remove([0xffffffff,0]) - self.timeIntervals.append(intv) - def getRunFillNr(self,fnam): - splt = fnam.split('_') - rn = splt[1] - if rn == "Fill": - rn = splt[2] - rn = rn.split('.')[0] - return int(rn) - def Print(self): - print(self.exclRuns) - print(self.timeIntervals) - def matchFile(self,fnam): - st = None - for reg in self.KeepFileRegs: - st = reg.match(fnam) - if st != None: - break - if (st != None): - return False - st = None - for reg in self.DelFileRegs: - st = reg.match(fnam) - if st != None: - break - if (st == None): - return False - rn = self.getRunFillNr(fnam) -# print fnam,rn - if rn in self.keepRuns: -# print "skipping file "+fnam+" due to excluded run number" - return False - if rn in self.deleteRuns: - return True - st=os.stat(fnam) - for i in self.timeIntervals: - if (st.st_mtime > i[0]) and (st.st_mtime < i[1]):#self.timAfter: - return False - return True -def t(tval): - return time.mktime(time.strptime(tval,"%d %b %Y")) \ No newline at end of file diff --git a/Online/FarmConfig/job/DFMonSvcTest.sh b/Online/FarmConfig/job/DFMonSvcTest.sh deleted file mode 100644 index 25efa7fc86bbdd7b694fd4e668f50795dd1b4c6d..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/DFMonSvcTest.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -# -exec -a ${UTGID} ${DATAFLOW_task} -class=Class1 -opts=../options/DFMonSvcTest.opts $(AUTO_STARTUP} ${DEBUG_STARTUP} diff --git a/Online/FarmConfig/job/DQDefaultTask.sh b/Online/FarmConfig/job/DQDefaultTask.sh deleted file mode 100755 index b839e2b82b994818bdb088d9e65e56046e5ae066..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/DQDefaultTask.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -# -. /group/online/dataflow/cmtuser/DataQuality/Online/DataQuality/scripts/DefaultTask.sh; diff --git a/Online/FarmConfig/job/DWHiMu.sh b/Online/FarmConfig/job/DWHiMu.sh deleted file mode 100644 index 3cc9335415c66b7b3557c837943e875abbe6e631..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/DWHiMu.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -# ========================================================================= -# -# Default script to start the data writer task on a farm node -# -# Author M.Frank -# Version: 1.0 -# Date: 20/05/2013 -# -# ========================================================================= -# -exec -a ${UTGID} ${DATAFLOW_task} -class=Class1 -opts=../options/${TASK_TYPE}.opts; diff --git a/Online/FarmConfig/job/DefHLT2Reader.sh b/Online/FarmConfig/job/DefHLT2Reader.sh deleted file mode 100755 index 546fb47c5e533de875b6bda32347430e4fd4a6b3..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/DefHLT2Reader.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -# -NODE=`hostname -s | tr a-z A-Z`; -export NODE_OPTIONS=${DYNAMIC_OPTS}/Nodes/${NODE}_TriggerInfo.opts; -##echo "[error] Go service name is: ${GO_SERVICE_NAME}"; -exec -a ${UTGID} ${Class2_task} -opts=../options/${TASK_TYPE}.opts diff --git a/Online/FarmConfig/job/DefMoore2.sh b/Online/FarmConfig/job/DefMoore2.sh deleted file mode 100755 index 4d83dee2982edab085b130136fd12855ffc0081d..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/DefMoore2.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -# ========================================================================= -# -# Default script to start the event reader task on the HLT farm -# -# Author M.Frank -# Version: 1.0 -# Date: 20/05/2013 -# -# ========================================================================= -# -export CMTCONFIG=x86_64-centos7-gcc62-opt; -export DAQ_INHIBIT_FINALIZE=ON; -. /group/hlt/MOORE/${MOOREONLINE_VERSION}/InstallArea/runMooreHlt2Online_EFF.sh ${DIM_DNS_NODE} ${PARTITION_NAME} ${NBOFSLAVES}; diff --git a/Online/FarmConfig/job/DefaultCriteria.py b/Online/FarmConfig/job/DefaultCriteria.py deleted file mode 100755 index fc106c2c75a488ef3f2ab842245b5ec0dc3e4b03..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/DefaultCriteria.py +++ /dev/null @@ -1,7 +0,0 @@ -import sys -import os -import Criteria - -Crits=Criteria.Criteria() -Crits.__init__() -Crits.setBeforeTime("1 Jan 2016") diff --git a/Online/FarmConfig/job/DefaultTask.sh b/Online/FarmConfig/job/DefaultTask.sh deleted file mode 100755 index 8bbce262b5cd858cd07fbecb5a032f378c705989..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/DefaultTask.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash -#*****************************************************************************\ -# (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -# * -# This software is distributed under the terms of the GNU General Public * -# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -# * -# In applying this licence, CERN does not waive the privileges and immunities * -# granted to it by virtue of its status as an Intergovernmental Organization * -# or submit itself to any jurisdiction. * -#*****************************************************************************/ -# -export CMTCONFIG=x86_64-slc6-gcc49-do0; -cd /home/frankm/cmtuser/OnlineDev_v5r31; -. ./setup.${CMTCONFIG}.vars; -cd ${DATAFLOWROOT}/scripts; -export INFO_OPTIONS=/group/online/dataflow/options/MSF/MSF_Info.opts; -export SUBFARM_OPTIONS=${FARMCONFIGROOT}/options/Empty.opts; -# -# Use the data network for the data transfers.... -export TAN_PORT=YES; -export TAN_NODE=`hostname -s`; -export DATAINTEFACE=`hostname -s`; -export DATAINTERFACE=`python /group/online/dataflow/scripts/getDataInterface.py` -export TAN_PORT=YES -export TAN_NODE=${DATAINTERFACE} -# -export MSF_DataSink1="MONA1002::${PARTITION_NAME}_MONA1002_MSFRcv_0"; -export MSF_DataSink2="MONA1003::${PARTITION_NAME}_MONA1003_MSFRcv_0"; -export MSF_DataSink3="MONA1004::${PARTITION_NAME}_MONA1004_MSFRcv_0"; -# -export READER_NODE_OPTIONS=/group/online/dataflow/cmtuser/DQ/DATAQUALITY_OPT/ReaderInput.opts; -# -WORKERS=`echo ${DATAINTEFACE} | cut -b 1-7`; -if test "${PARTITION_NAME}" = "MSF" -a "${DATAINTEFACE}" = "mona1001";then - export MBM_CONFIG_OPTS=${DATAQUALITYROOT}/options/MSFReaderMBM.opts; - export MBM_SETUP_OPTIONS=/group/online/dataflow/architectures/lbDataflowArch_MSFReader_MBM_setup.opts; -elif test "${PARTITION_NAME}" = "MSF" -a "${WORKERS}" = "mona100";then - export MBM_CONFIG_OPTS=${DATAQUALITYROOT}/options/MSFWorkerMBM.opts; - export MBM_SETUP_OPTIONS=/group/online/dataflow/architectures/lbDataflowArch_MSFWorker_MBM_setup.opts; -fi; -# -export DATAFLOW_task="gentest.exe libDataflow.so dataflow_run_task -msg=Dataflow_FmcLogger -mon=Dataflow_DIMMonitoring" -# -if test -f ./${TASK_TYPE}.sh; -then - . ./${TASK_TYPE}.sh $*; -else - exec -a ${UTGID} ${Class1_task} -opts=../options/${TASK_TYPE}.opts; -fi; diff --git a/Online/FarmConfig/job/DistributeFiles.py b/Online/FarmConfig/job/DistributeFiles.py deleted file mode 100755 index da4a4ef125281e0cbcedc208bd19fe93b0074cb5..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/DistributeFiles.py +++ /dev/null @@ -1,166 +0,0 @@ -from __future__ import print_function -from __future__ import division -from builtins import str -from builtins import range -from past.utils import old_div -import sys -import os -import re -import socket -FarmConfig=dict() -FarmConfig['a01']=list(range(5,29)) -FarmConfig['a02']=list(range(5,29)) -FarmConfig['a03']=list(range(5,29)) -FarmConfig['a04']=list(range(5,29)) -FarmConfig['a05']=list(range(5,29)) -FarmConfig['a06']=list(range(5,29)) -FarmConfig['a07']=list(range(5,29)) -FarmConfig['a08']=list(range(5,29)) -FarmConfig['a09']=list(range(5,29)) -FarmConfig['a10']=list(range(5,29)) - -FarmConfig['b01']=list(range(5,29)) -FarmConfig['b02']=list(range(5,29)) -FarmConfig['b03']=list(range(5,29)) -FarmConfig['b04']=list(range(5,29)) -FarmConfig['b05']=list(range(5,29)) -FarmConfig['b06']=list(range(5,29)) -FarmConfig['b07']=list(range(5,29)) -FarmConfig['b08']=list(range(5,29)) -FarmConfig['b09']=list(range(5,29)) -FarmConfig['b10']=list(range(5,29)) - -FarmConfig['c01']=list(range(5,29)) -FarmConfig['c02']=list(range(5,29)) -FarmConfig['c03']=list(range(5,29)) -FarmConfig['c04']=list(range(5,29)) -FarmConfig['c05']=list(range(5,29)) -FarmConfig['c06']=list(range(5,29)) -FarmConfig['c07']=list(range(5,29)) -FarmConfig['c08']=list(range(5,29)) -FarmConfig['c09']=list(range(5,29)) -FarmConfig['c10']=list(range(5,29)) - -FarmConfig['d01']=list(range(5,29)) -FarmConfig['d02']=list(range(5,29)) -FarmConfig['d03']=list(range(5,29)) -FarmConfig['d04']=list(range(5,29)) -FarmConfig['d05']=list(range(5,29)) -FarmConfig['d06']=list(range(5,29)) -FarmConfig['d07']=list(range(5,29)) -FarmConfig['d08']=list(range(5,29)) -FarmConfig['d09']=list(range(5,29)) -FarmConfig['d10']=list(range(5,29)) - -FarmConfig['e01']=list(range(5,29)) -FarmConfig['e02']=list(range(5,29)) -FarmConfig['e03']=list(range(5,29)) -FarmConfig['e04']=list(range(5,29)) -FarmConfig['e05']=list(range(5,29)) -FarmConfig['e06']=list(range(5,29)) -FarmConfig['e07']=list(range(5,29)) -FarmConfig['e08']=list(range(5,29)) -FarmConfig['e09']=list(range(5,29)) -FarmConfig['e10']=list(range(5,29)) - -FarmConfig['f01']=list(range(5,33)) -FarmConfig['f02']=list(range(5,33)) -FarmConfig['f03']=list(range(5,33)) -FarmConfig['f04']=list(range(5,33)) -FarmConfig['f05']=list(range(5,33)) -FarmConfig['f06']=list(range(5,33)) -FarmConfig['f07']=list(range(5,33)) -FarmConfig['f08']=list(range(1,33)) -FarmConfig['f09']=list(range(1,33)) -FarmConfig['f10']=list(range(1,33)) -FarmConfig['f11']=list(range(1,33)) -FarmConfig['f12']=list(range(1,33)) - -FarmConfig['m01']=list(range(1,13)) -FarmConfig['m02']=list(range(1,13)) - -def selectFiles(srcdir): - sfiles = os.listdir(srcdir) - return sfiles -print(len(sys.argv), sys.argv) -if len(sys.argv) == 3: - srcdir = sys.argv[1] - destfarm = sys.argv[2] - exself=False - network = "-d1" -elif len(sys.argv) == 4: - srcdir = sys.argv[1] - destfarm = sys.argv[2] - network="-d1" - exself=True -elif len(sys.argv) == 5: - srcdir = sys.argv[1] - destfarm = sys.argv[2] - network = '-d1' - if sys.argv[4] == 'control': - network= '' -# network=sys.argv[4] - exself=True -else: - print("Insuffienct Number of Arguments\nUsage:\n\tDistributeFiles <srcdir> <destfarm> <noself> <network\n") - exit(0) -print("executing with ",srcdir, destfarm, exself, network) -destdev = os.path.split(srcdir)[0] -destdir = 'hlt_COPY' -sfiles = selectFiles(srcdir) -sfiles.sort() -nfiles = len(sfiles) -MyName = socket.gethostname() -MyName=MyName.lower() -MyFarm = MyName[3:6] -destfarm=destfarm.lower() -nnodes=len(FarmConfig[destfarm]) -#print exself, MyFarm,destfarm, MyName -if exself and destfarm==MyFarm: - nnodes = nnodes-1 - print("Same farm ",MyFarm," and Self node excluded. Reduced Number of nodes to",nnodes) -fpernode = old_div(nfiles,nnodes) -nrest = nfiles % nnodes -# destdir="hlt_COPY" -nmap = dict() -nods = [] -totf=0 -for i in FarmConfig[destfarm]: - nod = "hlt%s%02d"%(destfarm,i,) - if exself and nod==MyName: - continue - nods.append(nod) -j=0 -for nod in nods: - nmap[nod] = [sfiles[l] for l in range(j*fpernode,(j+1)*fpernode)] - j=j+1 -# print nod,len(nmap[nod]),nmap[nod] -fbase = nnodes*fpernode -try: - srcdir.index('2') - postfix = '2' -except: - postfix='1' - -for i in range(nrest): - nod = nods[i] - nmap[nod].append(sfiles[fbase+i]) -# print nod,len(nmap[nod]),nmap[nod] -for nod in nods: - totf += len(nmap[nod]) -print("Number of files in directory "+str(nfiles)+" number of files in map "+str(totf)) -for nod in nods: - cfname = "/tmp/"+nod+"_"+postfix+".sh" - f = open(cfname,"w") - f.write("#!/bin/bash\n") - for j in range(len(nmap[nod])): - if nod==MyName: - f.write("cp "+srcdir+"/"+nmap[nod][j]+" "+destdev+"/"+destdir+"\n") - else: - f.write("scp "+srcdir+"/"+nmap[nod][j]+" online@"+nod+network+":"+destdev+"/"+destdir+"\n") - f.close() - cmd = "chmod 777 "+cfname - os.system(cmd) - cmd = cfname+" &" - print("excuting "+cmd+"\n") - os.system(cmd) diff --git a/Online/FarmConfig/job/DskReader.sh b/Online/FarmConfig/job/DskReader.sh deleted file mode 100755 index 33615f547b0057e07dce330b3d6d8260d787bc6d..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/DskReader.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -# -NODE=`hostname -s | tr a-z A-Z`; -#export NODE_OPTIONS=${DYNAMIC_OPTS}/Nodes/${NODE}_TriggerInfo.opts; -export NODE_OPTIONS=../options/Empty.opts; -# echo "[ERROR] NODE_OPTIONS: ${NODE_OPTIONS}" > ${LOGFIFO}; -# -exec -a ${UTGID} ${Class2_task} -opts=../options/${TASK_TYPE}.opts diff --git a/Online/FarmConfig/job/DskWriterNew.sh b/Online/FarmConfig/job/DskWriterNew.sh deleted file mode 100755 index 81ec48cf40d9c4e81e2a2defec00fade7481c4ab..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/DskWriterNew.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -# ========================================================================= -# -# Default script to start the data writer task on a farm node -# -# Author M.Frank -# Version: 1.0 -# Date: 20/05/2013 -# -# ========================================================================= -# -exec -a ${UTGID} ${Class1_task} -opts=../options/${TASK_TYPE}.opts diff --git a/Online/FarmConfig/job/DummyDataflow.sh b/Online/FarmConfig/job/DummyDataflow.sh deleted file mode 100755 index 3266b85bd3237169ce942f49da73f17938235802..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/DummyDataflow.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -# -echo exec -a ${UTGID} ${DATAFLOW_task} -class=Class1 -opts=../options/${TASK_TYPE}.opts ${AUTO_STARTUP} ${DEBUG_STARTUP}; -exec -a ${UTGID} ${DATAFLOW_task} -class=Class1 -opts=../options/${TASK_TYPE}.opts ${AUTO_STARTUP} ${DEBUG_STARTUP}; diff --git a/Online/FarmConfig/job/DummyTask.sh b/Online/FarmConfig/job/DummyTask.sh deleted file mode 100755 index c587af9d3f901b8735400a36ebadf27e3981b458..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/DummyTask.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -# ========================================================================= -# -# Default script to start a dummy task only following FSM transitions -# -# Author M.Frank -# Version: 1.0 -# Date: 20/05/2013 -# -# ========================================================================= -# -export LOGFIFO=/run/fmc/logSrv.fifo; -echo "Starting exec -a ${UTGID} ${Class1_task} -opt=../options/DummyTask.opts $*"; -exec -a ${UTGID} ${Class1_task} -opt=../options/DummyTask.opts $*; diff --git a/Online/FarmConfig/job/OvrReader.sh b/Online/FarmConfig/job/EBAdder.sh similarity index 66% rename from Online/FarmConfig/job/OvrReader.sh rename to Online/FarmConfig/job/EBAdder.sh index f872b743a24414ca1b67ad57d599b814fe58bbaa..fed133798929a53086266796286813b864eabf28 100755 --- a/Online/FarmConfig/job/OvrReader.sh +++ b/Online/FarmConfig/job/EBAdder.sh @@ -8,5 +8,5 @@ # Date: 20/05/2013 # # ========================================================================= -# -exec -a ${UTGID} ${Class2_task} -opts=../options/${TASK_TYPE}.opts +export LEVEL=EventBuilder; +exec -a ${UTGID} genPython.exe `which gaudirun.py` ./AddersFromArchitecture.py --application=Online::OnlineApplication; diff --git a/Online/FarmConfig/job/EBPass.sh b/Online/FarmConfig/job/EBPass.sh index 85772b9a812b95b74b10c732beba5ddcf8637286..368ffbbdb871c67800f931a2cfb29981da6411a0 100755 --- a/Online/FarmConfig/job/EBPass.sh +++ b/Online/FarmConfig/job/EBPass.sh @@ -9,51 +9,18 @@ # # ========================================================================= # -rm -rf /tmp/${UTGID}.py; -# -cat > /tmp/${UTGID}.py <</EOF -import Configurables -import GaudiOnline -import OnlineEnvBase as OnlineEnv -import os - -from Configurables import Online__FlowManager as FlowManager -application = GaudiOnline.Passthrough(outputLevel=OnlineEnv.OutputLevel, - partitionName=OnlineEnv.PartitionName, - partitionID=OnlineEnv.PartitionID, - classType=GaudiOnline.Class1) -items = os.environ['UTGID'].split('_') -id = items[-1] -application.setup_fifolog() -application.log(GaudiOnline.MSG_INFO,'+++ OnlineEnv: %s Level:%d',OnlineEnv.__file__,OnlineEnv.OutputLevel) -application.setup_mbm_access('Events_'+id, True) -writer = None -writer = application.setup_mbm_output('EventOutput') -writer.MBM_buffer = 'Output' -writer.MBM_maxConsumerWait = 10 -# -application.setup_hive(FlowManager("EventLoop"), 30) -application.setup_algorithms(writer=writer, acceptRate=0.01) -application.setup_monitoring() -# -writer.UseRawData = False -application.input.DeclareData = True -application.input.DeclareEvent = False -application.input.DeclareErrors = False -# -# -application.monSvc.DimUpdateInterval = 1 -application.config.numEventThreads = 1 -application.config.MBM_numConnections = 7 -application.config.MBM_numEventThreads = 6 -application.config.MBM_requests = [ - 'EvType=3;TriggerMask=0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF;VetoMask=0,0,0,0;MaskType=ANY;UserType=ONE;Frequency=PERC;Perc=20.0', - 'EvType=2;TriggerMask=0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF;VetoMask=0,0,0,0;MaskType=ANY;UserType=ONE;Frequency=PERC;Perc=20.0', - 'EvType=1;TriggerMask=0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF;VetoMask=0,0,0,0;MaskType=ANY;UserType=ONE;Frequency=PERC;Perc=20.0' -] -/EOF -# -# -export PYTHONPATH=/group/online/dataflow/options/${PARTITION}:${PYTHONPATH}; -###export RTL_SLEEP_ON_FATAL=1; -exec -a ${UTGID} genPython.exe `which gaudirun.py` /tmp/${UTGID}.py --application=OnlineEvents +if [[ "$UTGID" == *"${TASK_TYPE}_0"* ]]; then + export MBM_INPUT_BUFFER=Events_0; +elif [[ "$UTGID" == *"${TASK_TYPE}_1"* ]]; then + export MBM_INPUT_BUFFER=Events_1; +elif [[ "$UTGID" == *"${TASK_TYPE}_2"* ]]; then + export MBM_INPUT_BUFFER=Events_0; +elif [[ "$UTGID" == *"${TASK_TYPE}_3"* ]]; then + export MBM_INPUT_BUFFER=Events_1; +elif [[ "$UTGID" == *"${TASK_TYPE}_4"* ]]; then + export MBM_INPUT_BUFFER=Events_0; +else + export MBM_INPUT_BUFFER=Events_1; +fi; +# +execute `gaudi_event_task ${FARMCONFIGROOT}/job/Passthrough.py`; diff --git a/Online/FarmConfig/job/EBReader.sh b/Online/FarmConfig/job/EBReader.sh new file mode 100644 index 0000000000000000000000000000000000000000..49cb5303fa7b86d4e2f1f6bba135979cede579b4 --- /dev/null +++ b/Online/FarmConfig/job/EBReader.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# ========================================================================= +# +# Default script to start the buffer manager on the HLT farm worker node +# +# Author M.Frank +# Version: 1.0 +# Date: 05/03/2021 +# +# ========================================================================= +# +if [[ "$UTGID" == *"${TASK_TYPE}_0"* ]]; then + export MBM_OUTPUT_BUFFER=Events_0; +elif [[ "$UTGID" == *"${TASK_TYPE}_1"* ]]; then + export MBM_OUTPUT_BUFFER=Events_1; +elif [[ "$UTGID" == *"${TASK_TYPE}_2"* ]]; then + export MBM_OUTPUT_BUFFER=Events_0; +elif [[ "$UTGID" == *"${TASK_TYPE}_3"* ]]; then + export MBM_OUTPUT_BUFFER=Events_1; +elif [[ "$UTGID" == *"${TASK_TYPE}_4"* ]]; then + export MBM_OUTPUT_BUFFER=Events_0; +else + export MBM_OUTPUT_BUFFER=Events_1; +fi; +# +execute `dataflow_task ${CLASS}` -opts=${STATIC_OPTS}/${TASK_TYPE}.opts ${AUTO_STARTUP} ${DEBUG_STARTUP}; diff --git a/Online/FarmConfig/job/HLT1Sender.sh b/Online/FarmConfig/job/EBSender.sh similarity index 100% rename from Online/FarmConfig/job/HLT1Sender.sh rename to Online/FarmConfig/job/EBSender.sh diff --git a/Online/FarmConfig/job/EmptyJob.sh b/Online/FarmConfig/job/EmptyJob.sh deleted file mode 100755 index ab196762c53369250a816454b01e886b67a6741a..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/EmptyJob.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -# -. /home/frankm/cmtuser/OnlineDev_v5r17/setup.x86_64-slc6-gcc48-dbg.vars; -export PY_EXE=`which python`; -export PYTHONHOME=`dirname $PY_EXE`; -export PYTHONHOME=`dirname $PYTHONHOME`; -# -exec -a ${UTGID} `which python` -c "import HLT2.DimInterface as FSM; FSM.runVoidTask(name='${UTGID}',auto=True)"; diff --git a/Online/FarmConfig/job/EvtsPub.sh b/Online/FarmConfig/job/EvtsPub.sh deleted file mode 100755 index d971cadd44242f68c6d33cb6466e76f95678eeb5..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/EvtsPub.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# ========================================================================= -# -# Default script to start the event reader task on the HLT farm -# -# Author M.Frank -# Version: 1.0 -# Date: 20/05/2013 -# -# ========================================================================= -# -#!/bin/bash -. /group/online/dataflow/scripts/preamble.sh; -export ONLINE_VERSION=`python -c "import os;s=os.environ['DIMROOT'];i=s.find('/ONLINE_');print s[i+1:i+1+s[i+1:].find('/')]"`; -# -TASKCLASS=-tasktype=LHCb::${2}Task; -TASKTYPE=${3}; -export DIM_DNS_NODE=${4}; -DYNAMIC_OPTS=/group/online/dataflow/options; -OPTIONS=${DYNAMIC_OPTS}/${PARTITION}/${1}; -# -# -#export PREAMBLE_OPTS=${ONLINETASKS}/options/Preamble.opts; -export ONLINE_ENV_DIR=/group/online/dataflow/options/${PARTITION}/MONITORING -export PYTHONPATH=${ONLINE_ENV_DIR}:${PYTHONPATH} -export AdderOptsFile=/tmp/${PARTITION}_MonAdderOpts.opts; -export AdderStaticOpts=../options/NodeAdderStatic.opts; -cd /group/online/dataflow/cmtuser/OnlineRelease/Online/FarmConfig/job; -python ./MonAdderOpts.py ${AdderOptsFile} -# -###export LD_LIBRARY_PATH=/home/beat/cmtuser/myOnline/InstallArea/${CMTCONFIG}/lib:$LD_LIBRARY_PATH -##echo $Class1_task -export INFO_OPTIONS=/group/online/dataflow/options/${PARTITION}/${PARTITION}_Info.opts -# -exec -a ${UTGID} $gaudi_exe ${TASKCLASS} -opt=../options/genAdder.opts -main=${ONLINETASKS}/options/Main.opts - diff --git a/Online/FarmConfig/job/FarmModels.py b/Online/FarmConfig/job/FarmModels.py deleted file mode 100755 index 32c9d3f6963193a265dab32d616838e51c242c0d..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/FarmModels.py +++ /dev/null @@ -1,40 +0,0 @@ -from __future__ import print_function -#import sys -from builtins import range -import os -dire = '/home/beat/CPUInfo' -fils = os.listdir(dire) -fils.sort() -typmap={} -for i in range(len(fils)): - f = open(dire+'/'+fils[i],"r") - node = '' - node = fils[i][0:8] - lins = f.readlines() - f.close() - modname = '' - modnum = '' - for j in range(len(lins)): - splitlin = lins[j].split(':') - mod = splitlin[0].split('\t')[0] - if mod == 'model': - modnum = splitlin[1].replace('\t','') - modnum = modnum.replace('\n','') - modnum = modnum.replace(' ','') - else: - modname = splitlin[1].replace('\t','') - modname = modname.replace('\n','') - if modname[0] == ' ': - modname = modname[1:] - while 1: - modn = modname.replace(' ',' ') - if modn == modname: - break - else: - modname = modn - print(node,modnum,modname) - if modnum in typmap: - typmap[modnum].append(node) - else: - typmap[modnum] = [node] - diff --git a/Online/FarmConfig/job/Farm_CPUModels.py b/Online/FarmConfig/job/Farm_CPUModels.py deleted file mode 100755 index 780f4c939d78f1ed85889a41ed9b4c4782f20e71..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/Farm_CPUModels.py +++ /dev/null @@ -1,143 +0,0 @@ -from __future__ import print_function -from __future__ import division -from builtins import range -from past.utils import old_div -import sys -import os -import re -import socket -nod28 = set() -quad28=set() -quad32=set() -for i in range(28): - nod28.add("{0:02d}".format(i+1)) -nod32 = set() -for i in range(32): - nod32.add("{0:02d}".format(i+1)) -for i in range(7): - quad28.add(i) -for i in range(8): - quad32.add(i) -# print "Quad28 ",quad28 -# print "Quad32 ",quad32 - -ExpNods=dict() -ExpNods["A"]=28 -ExpNods["B"]=28 -ExpNods["C"]=28 -ExpNods["D"]=28 -ExpNods["E"]=28 -ExpNods["F"]=32 - -def fixmissing(nrs,nod): -# print nrs,nod - nods=set() - quads=set() - missq=set() - row = nod[0][3] -# print nod[0],row," Expected number of nodes ",ExpNods[row] - for i in range(len(nrs)): - nods.add(nrs[i]) - quads.add((old_div((int(nrs[i])-1),4))) - if len(nods) == ExpNods[row]: - return -# print "Incomplete Subfarm",nod - if len(nrs) < ExpNods[row]: - if (ExpNods[row] == 28): - miss = nod28.difference(nods) - missq = quad28.difference(quads) - elif ExpNods[row]== 32: - miss=nod32.difference(nods) - missq = quad32.difference(quads) -# return - if len(miss) == 0: - return - nodnrarr=[] - if len(missq) != 0: - print("Missing Quads in Farm "+nod[0][0:6],missq) - for i in miss: - nodnr=int(i) - nodnrarr.append(nodnr) - nodnrarr.sort() - for i in nodnrarr:#range(len(nodnrarr)): - nodstr="{0:02d}".format(i) - nrs.insert(i,nodstr) - newnode= nod[0][0:6]+nodstr - quad = old_div((i-1),4) - nodinquad = (i-1) % 4 -# print i,quad,nodinquad, newnode -# print nod -# print "Inserting at "+str(i) - nod.insert(i,newnode+" Slow INSERTED") - print("Inserted missing node "+newnode) - nod.sort() - if quad in missq: - continue - for j in range(len(nod)): - if nod[j].find(newnode) != -1: - break - if nodinquad ==0: -# print nod[j],nod[j] - try : - nod[j]=newnode+" "+nod[j+1][9:] - except: - nod[j]=newnode+" "+nod[j-1][9:] - else: -# print nod[j],nod[j-1] - nod[j]=newnode+" "+nod[j-1][9:] - nod.sort() -# print nod -if len(sys.argv) >= 2: - InFilen = sys.argv[1] -else: - print("Insufficient Number of Arguments\nUsage:\n\tFarmCPUModels.py <InputFileName>\n") - exit(0) -f = open(InFilen,"r") -nodes = f.readlines() -f.close() -nodes.sort() -nodmap=dict() -nodnrs=dict() -for i in range(len(nodes)): - nodes[i]=nodes[i].replace("========> ","") - nodes[i]=nodes[i].replace(nodes[i][0:8],nodes[i][0:8].upper()) - nodes[i]=nodes[i].replace("Manufacturer: ","") - nodes[i]=nodes[i].replace("\n","") - node = nodes[i][0:8] - manuf = nodes[i][9:] - if manuf.find("Intel") != -1: - manuf = "Fast "+manuf - elif manuf.find("ASUSTeK") != -1: - manuf = "Medium "+manuf - elif manuf.find("Dell") != -1: - manuf = "Slow "+manuf - elif manuf.find("ACTION") != -1: - manuf = "Slow "+manuf - elif manuf.find("Supermicro") != -1: - manuf = "Slow ACTION SA" - elif manuf.find("Quanta") != -1: - manuf = "Faster "+manuf - elif manuf.find("Inventec") != -1: - manuf = "Slow Dell" - nodes[i] = node+" "+manuf - farm = node[3:6] - nod = node[6:8]; -# print node,farm,nod, manuf - if (farm in nodmap) == False: - nodmap[farm] = [] - nodmap[farm].append(nodes[i]) - if (farm in nodnrs) == False: - nodnrs[farm] = [] - nodnrs[farm].append(nod); -for k in nodnrs.keys(): - fixmissing(nodnrs[k],nodmap[k]) -final=[] -f=open("/group/online/ecs/FarmNodes.txt","w+") -# f=open("/tmp/FarmNodes.txt","w+") -for k in nodmap.keys(): - for l in range(len(nodmap[k])): - final.append(nodmap[k][l]+"\n") -final.sort() -f.writelines(final) -f.close() - diff --git a/Online/FarmConfig/job/Farm_CPUModels_Run3.py b/Online/FarmConfig/job/Farm_CPUModels_Run3.py deleted file mode 100755 index 43a9421ae7c13f947e386db7dbbcdf26d97ef28f..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/Farm_CPUModels_Run3.py +++ /dev/null @@ -1,305 +0,0 @@ -from __future__ import print_function -from __future__ import division -from builtins import range -from past.utils import old_div -import sys -import os -import re -import socket -nod28 = set() -nod32 = set() -nod40 = set() -quad28=set() -quad32=set() -quad40=set() -for i in range(28): - nod28.add("{0:02d}".format(i+1)) -for i in range(32): - nod32.add("{0:02d}".format(i+1)) -for i in range(40): - nod40.add("{0:02d}".format(i+1)) -for i in range(7): - quad28.add(i) -for i in range(8): - quad32.add(i) -for i in range(10): - quad40.add(i) -# print "Quad28 ",quad28 -# print "Quad32 ",quad32 - -ExpNods=dict() -ExpNods["a"]=28 -ExpNods["b"]=28 -ExpNods["c"]=28 -ExpNods["d"]=28 -ExpNods["e"]=28 -ExpNods["f"]=32 -ExpNods["2"]=40 -NodeModNums = dict() -NodeModNums['1'] = "Medium" -NodeModNums['44'] = "Slow" - -NodeModNums['79'] = "Faster" -NodeModNums['63'] = "Fast" -def fixmissing(nrs,nod): -# print nrs,nod - nods=set() - quads=set() - missq=set() - row = nod[0][3] -# print nod[0],row," Expected number of nodes ",ExpNods[row] - for i in range(len(nrs)): - nods.add(nrs[i]) - quads.add((old_div((int(nrs[i])-1),4))) - if len(nods) == ExpNods[row]: - return -# print "Incomplete Subfarm",nod - if len(nrs) < ExpNods[row]: - if (ExpNods[row] == 28): - miss = nod28.difference(nods) - missq = quad28.difference(quads) - elif ExpNods[row]== 32: - miss=nod32.difference(nods) - missq = quad32.difference(quads) -# return - if len(miss) == 0: - return - nodnrarr=[] - if len(missq) != 0: - print("Missing Quads in Farm "+nod[0][0:6],missq) - for i in miss: - nodnr=int(i) - nodnrarr.append(nodnr) - nodnrarr.sort() - for i in nodnrarr:#range(len(nodnrarr)): - nodstr="{0:02d}".format(i) - nrs.insert(i,nodstr) - newnode= nod[0][0:6]+nodstr - quad = old_div((i-1),4) - nodinquad = (i-1) % 4 -# print i,quad,nodinquad, newnode -# print nod -# print "Inserting at "+str(i) - nod.insert(i,newnode+" Slow INSERTED") - print("Inserted missing node "+newnode) - nod.sort() - if quad in missq: - continue - for j in range(len(nod)): - if nod[j].find(newnode) != -1: - break - if nodinquad ==0: -# print nod[j],nod[j] - try : - nod[j]=newnode+" "+nod[j+1][9:] - except: - nod[j]=newnode+" "+nod[j-1][9:] - else: -# print nod[j],nod[j-1] - nod[j]=newnode+" "+nod[j-1][9:] - nod.sort() -# print nod -class Node(): - f = None - s = "" - def __init__(self): - self.File = "" - self.Name="" - self.Model="" - self.ModelName="" - self.SFarm="" - self.Row="" - self.Rack="" - self.Node=0 - self.Numproc = 0 - self.Quad = 0 - def setupMissing(self,nod,Model="0",ModelName="INSERTED"): - self.Name = nod - self.Row = nod[3:4] - self.SFarm = nod[4:6] - self.Node = int(nod[6:8]) - self.Quad = ((int(self.Node)-1) % 4)+1 - self.Model = Model - self.ModelName = ModelName - def setup(self,nod): - self.file = '/home/beat/CPUInfo/'+nod+"_CPUModel" - self.Name = nod; - self.Row = nod[3:4] - self.SFarm = nod[4:6] - self.Node = int(nod[6:8]) - self.Quad = (int(int(self.Node-1) / 4))+1 - self.f=open(self.file,"r") - lines=self.f.readlines() - self.f.close() - lines[0]=lines[0][0:len(lines[0])-1] - linec=lines[0].split(":") - self.Model=linec[1][1:] - lines[1]=lines[1][0:len(lines[1])-1] - linec=lines[1].split(":") - self.ModelName = linec[1][1:] - s="" - while True: - s = self.ModelName.replace(" "," ") - if s != self.ModelName: - self.ModelName = s - continue - else: - break - self.Numproc = len(lines)-2 -outf = "/group/online/ecs/FarmNodes.txt" -if len(sys.argv) >= 3: - InFilen = sys.argv[1] - outf = sys.argv[2] -elif len(sys.argv) >=2: - InFilen = sys.argv[1] -else: - print("Insufficient Number of Arguments\nUsage:\n\tFarmCPUModels.py <InputFileName> <OutputFile\n") - exit(0) -nods=[] -Nods = dict() -dirlist = os.listdir('/home/beat/CPUInfo') -dirlist=sorted(dirlist) -for i in dirlist: - nod = i[0:i.find('_')] - n=Node() - n.setup(nod) - nods.append(n) - Nods[nod] = n; -Models={} -SubFarms={} -for i in nods: - model = i.Model+" "+i.ModelName - if Models.has_key(model): - Models[model].append(i) - else: - Models[model] = [] - Models[model].append(i) - sf = i.Row+i.SFarm - if SubFarms.has_key(sf): - SubFarms[sf].add(i.Node) - else: - SubFarms[sf]=set() - SubFarms[sf].add(i.Node) - -for i in sorted(SubFarms.keys()): - row = i[0] - numnods = ExpNods[row] - existNodes = sorted(SubFarms[i]) - AllNodes = set(range(numnods+1)) - AllNodes.remove(0) - missnodes=AllNodes.difference(existNodes) - - outstr=i+":" - for j in sorted(SubFarms[i]): - outstr = outstr+" "+str(j) -# print(outstr) -# print("Missing Nodes: ",sorted(missnodes)) - quads = dict() - for k in range(ExpNods[row]/4 +1): - if k == 0: - continue - quads[k] = set() - for k in existNodes: - nname = "hlt"+i+"{0:02d}".format(k) - quads[Nods[nname].Quad].add(nname) -# print(quads) - for k in missnodes: - missname = "hlt"+i+"{0:02d}".format(k) - qnum = int((k-1)/4)+1 - if len(quads[qnum]) >0: - for j in quads[qnum]: - n = Node() - pattname= j - pattnode = Nods[pattname] - n.setupMissing(missname, pattnode.Model) - nods.append(n) - Nods[missname] = n; - try : - Models[n.Model+" "+n.ModelName].append(n) - except: - Models[n.Model+" "+n.ModelName]=[] - Models[n.Model+" "+n.ModelName].append(n) - break - else: - n = Node() - n.setupMissing(missname) - nods.append(n) - Nods[missname] = n; - try : - Models[n.Model+" "+n.ModelName].append(n) - except: - Models[n.Model+" "+n.ModelName]=[] - Models[n.Model+" "+n.ModelName].append(n) -for i in sorted(Models.keys()): - if i.find('INSERTED') >= 0: - continue - for j in Models[i]: - ncore = j.Numproc - break - print(i, "Number of Cores: ",ncore) - -for i in sorted(Models.keys()): - outstr = i+": " - for j in Models[i]: - outstr = outstr+j.Name+" " - outstr = outstr+"\n" -# print(outstr) -for i in sorted(Nods): - print(Nods[i].Name,Nods[i].Model,Nods[i].Numproc, Nods[i].ModelName) -# f = open(InFilen,"r") -# nodes = f.readlines() -# f.close() -# nodes.sort() -# nodmap=dict() -# nodnrs=dict() -# for i in range(len(nodes)): -# # nodes[i]=nodes[i].replace("========> ","") -# # nodes[i]=nodes[i].replace(nodes[i][0:8],nodes[i][0:8].upper()) -# # nodes[i]=nodes[i].replace("Manufacturer: ","") -# # nodes[i]=nodes[i].replace("\n","") -# # node = nodes[i][0:8] -# # manuf = nodes[i][9:] -# nodes[i]=nodes[i].replace("\n","") -# nodspl = nodes[i].split(" ") -# node = nodspl[0] -# node = node.upper() -# modelnr = nodspl[1] -# manuf ="" -# for j in range(2,len(nodspl)): -# manuf = manuf+" "+nodspl[j] -# # if manuf.find("Intel") != -1: -# # manuf = "Fast "+manuf -# # elif manuf.find("ASUSTeK") != -1: -# # manuf = "Medium "+manuf -# # elif manuf.find("Dell") != -1: -# # manuf = "Slow "+manuf -# # elif manuf.find("ACTION") != -1: -# # manuf = "Slow "+manuf -# # elif manuf.find("Supermicro") != -1: -# # manuf = "Slow ACTION SA" -# # elif manuf.find("Quanta") != -1: -# # manuf = "Faster "+manuf -# # elif manuf.find("Inventec") != -1: -# # manuf = "Slow Dell" -# nodes[i] = node+" "+NodeModNums[modelnr]+" "+manuf -# farm = node[3:6] -# nod = node[6:8]; -# # print node,farm,nod, manuf -# if (farm in nodmap) == False: -# nodmap[farm] = [] -# nodmap[farm].append(nodes[i]) -# if (farm in nodnrs) == False: -# nodnrs[farm] = [] -# nodnrs[farm].append(nod); -# for k in nodnrs.keys(): -# fixmissing(nodnrs[k],nodmap[k]) -# final=[] -# f=open(outf,"w+") -# # f=open("/tmp/FarmNodes.txt","w+") -# for k in nodmap.keys(): -# for l in range(len(nodmap[k])): -# final.append(nodmap[k][l]+"\n") -# final.sort() -# f.writelines(final) -# f.close() - diff --git a/Online/FarmConfig/job/Farm_CPUModels_new.py b/Online/FarmConfig/job/Farm_CPUModels_new.py deleted file mode 100755 index 4481f095c2267d46f384f395d7a8ffe9101744a7..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/Farm_CPUModels_new.py +++ /dev/null @@ -1,159 +0,0 @@ -from __future__ import print_function -from __future__ import division -from builtins import range -from past.utils import old_div -import sys -import os -import re -import socket -nod28 = set() -quad28=set() -quad32=set() -for i in range(28): - nod28.add("{0:02d}".format(i+1)) -nod32 = set() -for i in range(32): - nod32.add("{0:02d}".format(i+1)) -for i in range(7): - quad28.add(i) -for i in range(8): - quad32.add(i) -# print "Quad28 ",quad28 -# print "Quad32 ",quad32 - -ExpNods=dict() -ExpNods["A"]=28 -ExpNods["B"]=28 -ExpNods["C"]=28 -ExpNods["D"]=28 -ExpNods["E"]=28 -ExpNods["F"]=32 -NodeModNums = dict() -NodeModNums['1'] = "Medium" -NodeModNums['44'] = "Slow" -NodeModNums['79'] = "Faster" -NodeModNums['63'] = "Fast" -def fixmissing(nrs,nod): -# print nrs,nod - nods=set() - quads=set() - missq=set() - row = nod[0][3] -# print nod[0],row," Expected number of nodes ",ExpNods[row] - for i in range(len(nrs)): - nods.add(nrs[i]) - quads.add((old_div((int(nrs[i])-1),4))) - if len(nods) == ExpNods[row]: - return -# print "Incomplete Subfarm",nod - if len(nrs) < ExpNods[row]: - if (ExpNods[row] == 28): - miss = nod28.difference(nods) - missq = quad28.difference(quads) - elif ExpNods[row]== 32: - miss=nod32.difference(nods) - missq = quad32.difference(quads) -# return - if len(miss) == 0: - return - nodnrarr=[] - if len(missq) != 0: - print("Missing Quads in Farm "+nod[0][0:6],missq) - for i in miss: - nodnr=int(i) - nodnrarr.append(nodnr) - nodnrarr.sort() - for i in nodnrarr:#range(len(nodnrarr)): - nodstr="{0:02d}".format(i) - nrs.insert(i,nodstr) - newnode= nod[0][0:6]+nodstr - quad = old_div((i-1),4) - nodinquad = (i-1) % 4 -# print i,quad,nodinquad, newnode -# print nod -# print "Inserting at "+str(i) - nod.insert(i,newnode+" Slow INSERTED") - print("Inserted missing node "+newnode) - nod.sort() - if quad in missq: - continue - for j in range(len(nod)): - if nod[j].find(newnode) != -1: - break - if nodinquad ==0: -# print nod[j],nod[j] - try : - nod[j]=newnode+" "+nod[j+1][9:] - except: - nod[j]=newnode+" "+nod[j-1][9:] - else: -# print nod[j],nod[j-1] - nod[j]=newnode+" "+nod[j-1][9:] - nod.sort() -# print nod -outf = "/group/online/ecs/FarmNodes.txt" -if len(sys.argv) >= 3: - InFilen = sys.argv[1] - outf = sys.argv[2] -elif len(sys.argv) >=2: - InFilen = sys.argv[1] -else: - print("Insufficient Number of Arguments\nUsage:\n\tFarmCPUModels.py <InputFileName> <OutputFile\n") - exit(0) -f = open(InFilen,"r") -nodes = f.readlines() -f.close() -nodes.sort() -nodmap=dict() -nodnrs=dict() -for i in range(len(nodes)): -# nodes[i]=nodes[i].replace("========> ","") -# nodes[i]=nodes[i].replace(nodes[i][0:8],nodes[i][0:8].upper()) -# nodes[i]=nodes[i].replace("Manufacturer: ","") -# nodes[i]=nodes[i].replace("\n","") -# node = nodes[i][0:8] -# manuf = nodes[i][9:] - nodes[i]=nodes[i].replace("\n","") - nodspl = nodes[i].split(" ") - node = nodspl[0] - node = node.upper() - modelnr = nodspl[1] - manuf ="" - for j in range(2,len(nodspl)): - manuf = manuf+" "+nodspl[j] -# if manuf.find("Intel") != -1: -# manuf = "Fast "+manuf -# elif manuf.find("ASUSTeK") != -1: -# manuf = "Medium "+manuf -# elif manuf.find("Dell") != -1: -# manuf = "Slow "+manuf -# elif manuf.find("ACTION") != -1: -# manuf = "Slow "+manuf -# elif manuf.find("Supermicro") != -1: -# manuf = "Slow ACTION SA" -# elif manuf.find("Quanta") != -1: -# manuf = "Faster "+manuf -# elif manuf.find("Inventec") != -1: -# manuf = "Slow Dell" - nodes[i] = node+" "+NodeModNums[modelnr]+" "+manuf - farm = node[3:6] - nod = node[6:8]; -# print node,farm,nod, manuf - if (farm in nodmap) == False: - nodmap[farm] = [] - nodmap[farm].append(nodes[i]) - if (farm in nodnrs) == False: - nodnrs[farm] = [] - nodnrs[farm].append(nod); -for k in nodnrs.keys(): - fixmissing(nodnrs[k],nodmap[k]) -final=[] -f=open(outf,"w+") -# f=open("/tmp/FarmNodes.txt","w+") -for k in nodmap.keys(): - for l in range(len(nodmap[k])): - final.append(nodmap[k][l]+"\n") -final.sort() -f.writelines(final) -f.close() - diff --git a/Online/FarmConfig/job/FixPythonPath.py b/Online/FarmConfig/job/FixPythonPath.py deleted file mode 100644 index 203ba2a64c45253103fb599052c6fa45aac0c327..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/FixPythonPath.py +++ /dev/null @@ -1,13 +0,0 @@ -from __future__ import print_function -import os -nppath = '' -ppath = os.getenv('PYTHONPATH', "") -if ppath != '': -# print 'echo "[ERROR] =====>Old Python Path is: '+ppath+'";' - plist = ppath.split(':') - for i in plist: - if nppath != '': - nppath = nppath+":" - j = os.path.realpath(i) - nppath = nppath+j - print('export PYTHONPATH='+nppath+';') diff --git a/Online/FarmConfig/job/GaudiTest.py b/Online/FarmConfig/job/GaudiTest.py deleted file mode 100644 index c84b64374a0d7b23c9c89f81199d074ce79e6b21..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/GaudiTest.py +++ /dev/null @@ -1,43 +0,0 @@ -""" - Online Passthrough application configuration - - @author M.Frank -""" -__version__ = "1.0" -__author__ = "Markus Frank <Markus.Frank@cern.ch>" - -import Gaudi.Configuration as Gaudi -from GaudiOnline.OnlineApplication import * -import Configurables -from Configurables import MonitorSvc - -BusySvc = Configurables.BusySvc -HistPers = Configurables.HistogramPersistencySvc -print 'MSG_INFO: ',MSG_INFO - -class BusySvcApp(Application): - def __init__(self, outputLevel, partitionName='SF', partitionID=0xFFFF): - Application.__init__(self, - outputLevel=outputLevel, - partitionName=partitionName, - partitionID=partitionID, - classType=Class1) - self.config.automatic = True - self.app.HistogramPersistency = 'NONE' - HistPers.Warnings = False; - Bsv = BusySvc() - msv = MonitorSvc() - msv.OutputLevel = outputLevel - msv.CounterUpdateInterval = 5; - msv.PartitionName = "GEN"; - msv.ExpandCounterServices = True - print msv -# msv.OutDns = "ecs03" - Bsv.BogusMips = 0; - self.app.ExtSvc.append(msv) - self.app.ExtSvc.append(Bsv) -app = BusySvcApp(MSG_DEBUG, partitionName='LHCb') -print 'Setup complete....' -print dir(app) - - diff --git a/Online/FarmConfig/job/H2DefaultTask.sh b/Online/FarmConfig/job/H2DefaultTask.sh deleted file mode 100755 index b839e2b82b994818bdb088d9e65e56046e5ae066..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/H2DefaultTask.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -# -. /group/online/dataflow/cmtuser/DataQuality/Online/DataQuality/scripts/DefaultTask.sh; diff --git a/Online/FarmConfig/job/StorageAdder.sh b/Online/FarmConfig/job/HLT2Adder.sh similarity index 67% rename from Online/FarmConfig/job/StorageAdder.sh rename to Online/FarmConfig/job/HLT2Adder.sh index 5127a01815cffad7113b82f77ad972235c1255d7..728e4decd9f662e29377743ebd669cab6d93a856 100755 --- a/Online/FarmConfig/job/StorageAdder.sh +++ b/Online/FarmConfig/job/HLT2Adder.sh @@ -8,5 +8,5 @@ # Date: 20/05/2013 # # ========================================================================= -# - exec -a ${UTGID} ${Class1_task} -opts=../options/StorageAdder.opts; +export LEVEL=HltNode; +exec -a ${UTGID} genPython.exe `which gaudirun.py` ./AddersFromArchitecture.py --application=Online::OnlineApplication; diff --git a/Online/FarmConfig/job/HLT2LumiCounter.sh b/Online/FarmConfig/job/HLT2LumiCounter.sh deleted file mode 100755 index 81afb11697bb066d57deea5cbec637e1183e810f..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/HLT2LumiCounter.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -# -echo [DEBUG] SUBFARM_OPTIONS: ${SUBFARM_OPTIONS}; -exec -a ${UTGID} ${DATAFLOW_task} -class=Class2 -opts=../options/${TASK_TYPE}.opts diff --git a/Online/FarmConfig/job/HLT2Nanofier.sh b/Online/FarmConfig/job/HLT2Nanofier.sh deleted file mode 100755 index 0273e5e9bf8697e89641b7b18afd28f265af3b3d..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/HLT2Nanofier.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -# -export PYTHONPATH=${ONLINE_ENV_DIR}:${PYTHONPATH}; -# -cmd=`python <<EOF -import OnlineEnvBase as Online -print 'export EVENTSELECTOR_REQ1="EvType=2;TriggerMask=0x0,0x2,0x0,0x0;VetoMask=0,0,0,0;MaskType=ANY;UserType=VIP;Frequency=PERC;Perc=%f"'%(Online.AcceptRate*100.,); -EOF` -source /group/online/dataflow/cmtuser/OnlineBrunel/setup.x86_64-slc6-gcc49-dbg.vars -echo [DEBUG] $cmd; -eval $cmd; -export TAN_PORT=YES; -export TAN_NODE=${DATAINTERFACE}; -echo [DEBUG] SUBFARM_OPTIONS: ${SUBFARM_OPTIONS}; -echo [DEBUG] Eventselector request: ${EVENTSELECTOR_REQ1}; - -###exec -a ${UTGID} ${Class2_task} -opts=../options/HLT2Nanofier.opts -exec -a ${UTGID} $gaudi_task -tasktype=LHCb::Class2Task -main=../options/Hlt2Main.opts -opts=../options/HLT2Nanofier.opts diff --git a/Online/FarmConfig/job/EBMBM.sh b/Online/FarmConfig/job/HLT2Pass.sh similarity index 53% rename from Online/FarmConfig/job/EBMBM.sh rename to Online/FarmConfig/job/HLT2Pass.sh index e373c961ad3ebefa94180a8227d5591eaabed8b0..cac3ba3aefdfc7c12cd4a76b7b8dcb4f0cf95d1b 100755 --- a/Online/FarmConfig/job/EBMBM.sh +++ b/Online/FarmConfig/job/HLT2Pass.sh @@ -1,5 +1,5 @@ #!/bin/bash -# ========================================================================= +## ========================================================================= # # Default script to start the buffer manager on the HLT farm worker node # @@ -9,4 +9,4 @@ # # ========================================================================= # -`dataflow_task Class0` -opts=../options/${TASK_TYPE}.opts; +exec -a ${UTGID} genPython.exe `which gaudirun.py` ${FARMCONFIGROOT}/job/Passthrough.py --application=Online::OnlineEventApp; diff --git a/Online/FarmConfig/job/DskWriter.sh b/Online/FarmConfig/job/HLT2Reader.sh similarity index 53% rename from Online/FarmConfig/job/DskWriter.sh rename to Online/FarmConfig/job/HLT2Reader.sh index 3cc9335415c66b7b3557c837943e875abbe6e631..cf911c0d015a85c42da05a63b5493378e368346e 100755 --- a/Online/FarmConfig/job/DskWriter.sh +++ b/Online/FarmConfig/job/HLT2Reader.sh @@ -1,12 +1,12 @@ #!/bin/bash # ========================================================================= # -# Default script to start the data writer task on a farm node +# Generic farm task startup script # # Author M.Frank # Version: 1.0 # Date: 20/05/2013 # # ========================================================================= -# -exec -a ${UTGID} ${DATAFLOW_task} -class=Class1 -opts=../options/${TASK_TYPE}.opts; +#`dataflow_task Class2` -opts=../options/${TASK_TYPE}.opts +`dataflow_task Class2` -opts=/group/online/dataflow/cmtuser/OnlineRelease/TestBeam/options/MDFProd.opts diff --git a/Online/FarmConfig/job/HistogramAggregator.py b/Online/FarmConfig/job/HistogramAggregator.py deleted file mode 100644 index 9da5b333fd5ca4cd6f98122ef4ed9dd86c05c0c2..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/HistogramAggregator.py +++ /dev/null @@ -1,25 +0,0 @@ -import os -import os.path - -rootpath="/hist/Savesets/" -ByRun="/hist/Savesets/ByRun/" -Years=[] -years=os.listdir(rootpath) -for i in years: - if os.path.isdir(rootpath+i): - try: - dum = int(i) - except: - pass - else: - Years.append(i) -Parts=set() -for i in Years: - Parts.update(set(os.listdir(rootpath+i))) -tasks = set() -for i in Years: - for j in Parts: - try: - tasks.update(set(os.listdir(rootpath+i+'/'+j))) - except: - pass diff --git a/Online/FarmConfig/job/Hlt2Adder.sh b/Online/FarmConfig/job/Hlt2Adder.sh deleted file mode 100755 index bde0d4d9118993d0d5c2a647c3307c0266a83418..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/Hlt2Adder.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash -# ========================================================================= -# -# Script to start the HLT2 histogram adder on the farm -# -# Author R. Aaij -# Version: 1.0 -# Date: 16/07/2015 -# -# ========================================================================= -# -if test "`uname -a | grep \".el6\"`" != ""; # SLC6 -then - export CMTCONFIG=x86_64-slc6-gcc62-dbg -elif test "`uname -a | grep el7`" != ""; # SLC7 (Centos 7) -then - export CMTCONFIG=x86_64-centos7-gcc62-dbg -fi; -ulimit -m 20000000 -export PYTHONPATH="/group/online/dataflow/options/${PARTITION}/HLT:${PYTHONPATH}" -read COMMAND <<EOF -import GaudiKernel.ProcessJobOptions; from Gaudi.Configuration import importOptions; GaudiKernel.ProcessJobOptions.printing_level=3; from Hlt2Monitoring import Hlt2Adder; Hlt2Adder.configure() -EOF - -echo "[DEBUG] Hlt2Adder on ${HOSTNAME}" -. /group/hlt/monitoring/ONLINE/ONLINE_RELEASE/setup.$CMTCONFIG.vars -exec -a ${UTGID} ${Class1_task} -opt=command="${COMMAND}" diff --git a/Online/FarmConfig/job/Hlt2MEPInit.sh b/Online/FarmConfig/job/Hlt2MEPInit.sh deleted file mode 100755 index 896d03741719e79ea0c57945033ac1303da42851..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/Hlt2MEPInit.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# ========================================================================= -# -# Default script to start the buffer manager on the HLT farm worker node -# -# Author M.Frank -# Version: 1.0 -# Date: 20/05/2013 -# -# ========================================================================= -`dataflow_task Class0` -opts=../options/${TASK_TYPE}.opts diff --git a/Online/FarmConfig/job/Hlt2Pass.sh b/Online/FarmConfig/job/Hlt2Pass.sh deleted file mode 100755 index f8395154e504f17d21f0be3e7d37e94af68f6719..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/Hlt2Pass.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -# -NODE=`hostname -s | tr a-z A-Z`; -export GO_SERVICE_NAME=${PARTITION_NAME}_${NODE}/Trigger; -##echo "[error] Go service name is: ${GO_SERVICE_NAME}"; -cd ../../../TestBeam/job; -. ./Monitor.sh diff --git a/Online/FarmConfig/job/Hlt2Publisher.sh b/Online/FarmConfig/job/Hlt2Publisher.sh deleted file mode 100755 index 8b5d9250b0404452a9d3b7e641f66fcafa532c6e..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/Hlt2Publisher.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# ========================================================================= -# -# Script to start the HLT2 histogram adder on the farm -# -# Author R. Aaij -# Version: 1.0 -# Date: 16/07/2015 -# -# ========================================================================= -# -export TAN_PORT=YES; -export TAN_NODE=${DATAINTERFACE}; -export CMTCONFIG=x86_64-slc6-gcc48-opt; -read COMMAND <<EOF -import GaudiKernel.ProcessJobOptions; from Gaudi.Configuration import importOptions; GaudiKernel.ProcessJobOptions.printing_level=3; from Hlt2Monitoring import Hlt2Publisher; Hlt2Publisher.configure() -EOF - -unset LD_PRELOAD -exec -a ${UTGID} /home/raaij/cmtuser/OnlineDev_v5r25/InstallArea/x86_64-slc6-gcc48-dbg/bin/${Class1_task} -opt=command="${COMMAND}"; diff --git a/Online/FarmConfig/job/Hlt2Reader.sh b/Online/FarmConfig/job/Hlt2Reader.sh deleted file mode 100755 index b82bb7b003d7a0c6aca6f4560a851277f700ed52..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/Hlt2Reader.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -# -fname=Run_0013610198_pluscc08_20210714-144746-040_0324.mdf; -file=/group/online/dataflow/cmtuser/data/mdf/$fname; -if test -f /localdisk1/hlt1/${fname}; then - echo "Input file ${name}" > /dev/null; -else - cp $file /localdisk1/hlt1/; -fi; -NODE=`hostname -s | tr a-z A-Z`; -export GO_SERVICE_NAME=${PARTITION_NAME}_${NODE}/Trigger; -##echo "[error] Go service name is: ${GO_SERVICE_NAME}"; -`dataflow_task Class2` -opts=../options/${TASK_TYPE}.opts diff --git a/Online/FarmConfig/job/Hlt2Writer.sh b/Online/FarmConfig/job/Hlt2Writer.sh deleted file mode 100755 index c978ebf3f259e4b9759818772a68cd123a624c1c..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/Hlt2Writer.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -# -# export TAN_PORT=YES; -# export TAN_NODE=${DATAINTERFACE}; -# echo [DEBUG] SUBFARM_OPTIONS: ${SUBFARM_OPTIONS}; -`dataflow_task Class2` -opts=../options/${TASK_TYPE}.opts diff --git a/Online/FarmConfig/job/InputRate.py b/Online/FarmConfig/job/InputRate.py deleted file mode 100755 index 294c1754ba20bef27fd4d9c613c4196c27d3251d..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/InputRate.py +++ /dev/null @@ -1,237 +0,0 @@ -from __future__ import print_function -from __future__ import division -from builtins import str -from builtins import range -from past.utils import old_div -from builtins import object -import sys -import os -import re -import socket -import time -tintv=[] -class Stats(object): - def __init__(self): - self.nents = 0 - self.sum = 0.0 - self.sum2 = 0.0 - self.avg = 0.0 - self.rms = 0.0 - return - def add(self,ent): - if ent > 0.0: - self.nents += 1 - self.sum += ent - self.sum2 += ent*ent; - return - def clear(self): - self.nents = 0 - self.sum = 0.0 - self.sum2 = 0.0 - return - -def TStamp(x): - return x[0:x.find('.')] -def Node(x): - return x.split(',')[1] -def Perf(x): - return float(x.split(',')[2]) - -class Interval(object): - def __init__(self,l,h): - self.low = l - self.high = h - def In(self,x): -# print "comparing ",x," with [",self.low,",",self.high,"]" - return self.low<=x and x<=self.high - def ID(self): - return str((self.low+self.high)/2.0) - -class NodeType(object): - def __init__(self,typ,insts): - self.m_typ = typ; - self.Nodes = [] - self.Records=[] - self.ninsts=insts - self.stats=[] - for i in insts: - self.stats.append(Stats()) - return - def Nodein(self,nod): - return nod in self.Nodes - def pass1(self): - for x in self.Records: - p = Perf(x) - t=TStamp(x) - ft = time.mktime(time.strptime(t,'%d-%m-%Y %H:%M:%S')) - i=0 - for iv in tintv: - if iv.In(ft): - if i == 13: - pass - if (i ==0) or (i == 13): - if p < (3.0*self.ninsts[i]): - self.stats[i].add(p) - break - else: - self.stats[i].add(p) - break - - i+= 1 - for s in self.stats: - s.avg = old_div(s.sum,s.nents) - s.rms = (old_div(s.sum2,s.nents))-(s.avg*s.avg) - return - def pass2(self,valint): - for x in self.Records: - p = Perf(x) - t=TStamp(x) - ft = time.mktime(time.strptime(t,'%d-%m-%Y %H:%M:%S')) - i=0 - for iv in tintv: - if iv.In(ft): - if valint[i].In(p): - self.stats[i].add(p) - break - i+= 1 - for s in self.stats: - s.avg = old_div(s.sum,s.nents) - s.rms = (old_div(s.sum2,s.nents))-(s.avg*s.avg) - return - - def analyse(self): - self.pass1() - ivs=[] - for i in range(len(tintv)): - ivs.append(Interval(self.stats[i].avg-0.5*self.stats[i].avg,self.stats[i].avg+0.5*self.stats[i].avg)) - self.stats[i].clear() - self.pass2(ivs) - return - -nexNodes="HLTA0101 HLTA0102 HLTA0103 HLTA0104 HLTA0201 HLTA0202 HLTA0203 HLTA0204 HLTA0301 HLTA0302 HLTA0303 HLTA0304 HLTA0401 HLTA0402 HLTA0403 HLTA0404 HLTA0501 HLTA0502 HLTA0503 HLTA0504 HLTA0601 HLTA0602 HLTA0603 HLTA0604 HLTA0701 HLTA0702 HLTA0703 HLTA0704 HLTA0717 HLTA0718 HLTA0719 HLTA0720 HLTA0801 HLTA0802 HLTA0803 HLTA0804 HLTA0901 HLTA0902 HLTA0903 HLTA0904 HLTA1001 HLTA1002 HLTA1003 HLTA1004 HLTB0101 HLTB0102 HLTB0103 HLTB0104 HLTB0201 HLTB0202 HLTB0203 HLTB0204 HLTB0301 HLTB0302 HLTB0303 HLTB0304 HLTB0401 HLTB0402 HLTB0403 HLTB0404 HLTB0501 HLTB0502 HLTB0503 HLTB0504 HLTB0901 HLTB0902 HLTB0903 HLTB0904 HLTB1001 HLTB1002 HLTB1003 HLTB1004 HLTC0101 HLTC0102 HLTC0103 HLTC0104 HLTC0201 HLTC0202 HLTC0203 HLTC0204 HLTC0301 HLTC0302 HLTC0303 HLTC0304 HLTC0401 HLTC0402 HLTC0403 HLTC0404 HLTC0501 HLTC0502 HLTC0503 HLTC0504 HLTC0601 HLTC0602 HLTC0603 HLTC0604 HLTC0717 HLTC0718 HLTC0719 HLTC0720 HLTC0817 HLTC0818 HLTC0819 HLTC0820 HLTC0901 HLTC0902 HLTC0903 HLTC0904 HLTC0917 HLTC0918 HLTC0919 HLTC0920 HLTC1001 HLTC1002 HLTC1003 HLTC1004 HLTC1017 HLTC1018 HLTC1019 HLTC1020 HLTD0101 HLTD0102 HLTD0103 HLTD0104 HLTD0201 HLTD0202 HLTD0203 HLTD0204 HLTD0301 HLTD0302 HLTD0303 HLTD0304 HLTD0401 HLTD0402 HLTD0403 HLTD0404 HLTD0501 HLTD0502 HLTD0503 HLTD0504 HLTD0601 HLTD0602 HLTD0603 HLTD0604 HLTD0701 HLTD0702 HLTD0703 HLTD0704 HLTD0801 HLTD0802 HLTD0803 HLTD0804 HLTD0901 HLTD0902 HLTD0903 HLTD0904 HLTD1001 HLTD1002 HLTD1003 HLTD1004 HLTE0101 HLTE0102 HLTE0103 HLTE0104 HLTE0201 HLTE0202 HLTE0203 HLTE0204 HLTE0301 HLTE0302 HLTE0303 HLTE0304 HLTE0401 HLTE0402 HLTE0403 HLTE0404 HLTE0501 HLTE0502 HLTE0503 HLTE0504 HLTE0601 HLTE0602 HLTE0603 HLTE0604 HLTE0701 HLTE0702 HLTE0703 HLTE0704 HLTE0801 HLTE0802 HLTE0803 HLTE0804 HLTE0901 HLTE0902 HLTE0903 HLTE0904 HLTE1001 HLTE1002 HLTE1003 HLTE1004 HLTF0201 HLTF0202 HLTF0203 HLTF0204 HLTF0301 HLTF0302 HLTF0303 HLTF0304 HLTF0401 HLTF0402 HLTF0403 HLTF0404 HLTF0501 HLTF0502 HLTF0503 HLTF0504 HLTF0601 HLTF0602 HLTF0603 HLTF0604 HLTF0701 HLTF0702 HLTF0703 HLTF0704 HLTF0729 HLTF0730 HLTF0731 HLTF0732" -slowNodes="HLTA0101 HLTA0102 HLTA0103 HLTA0104 HLTA0105 HLTA0106 HLTA0107 HLTA0108 HLTA0109 HLTA0110 HLTA0111 HLTA0112 HLTA0201 HLTA0202 HLTA0203 HLTA0204 HLTA0205 HLTA0206 HLTA0207 HLTA0208 HLTA0209 HLTA0210 HLTA0211 HLTA0212 HLTA0301 HLTA0302 HLTA0303 HLTA0304 HLTA0305 HLTA0306 HLTA0307 HLTA0308 HLTA0309 HLTA0310 HLTA0311 HLTA0312 HLTA0401 HLTA0402 HLTA0403 HLTA0404 HLTA0405 HLTA0406 HLTA0407 HLTA0408 HLTA0409 HLTA0410 HLTA0411 HLTA0412 HLTA0501 HLTA0502 HLTA0503 HLTA0504 HLTA0505 HLTA0506 HLTA0507 HLTA0508 HLTA0509 HLTA0510 HLTA0511 HLTA0512 HLTA0601 HLTA0602 HLTA0603 HLTA0604 HLTA0605 HLTA0606 HLTA0607 HLTA0608 HLTA0609 HLTA0610 HLTA0611 HLTA0612 HLTA0617 HLTA0618 HLTA0619 HLTA0620 HLTA0701 HLTA0702 HLTA0703 HLTA0704 HLTA0705 HLTA0706 HLTA0707 HLTA0708 HLTA0709 HLTA0710 HLTA0711 HLTA0712 HLTA0717 HLTA0718 HLTA0719 HLTA0720 HLTA0801 HLTA0802 HLTA0803 HLTA0804 HLTA0805 HLTA0806 HLTA0807 HLTA0808 HLTA0809 HLTA0810 HLTA0811 HLTA0812 HLTA0817 HLTA0818 HLTA0819 HLTA0820 HLTA0901 HLTA0902 HLTA0903 HLTA0904 HLTA0905 HLTA0906 HLTA0907 HLTA0908 HLTA0909 HLTA0910 HLTA0911 HLTA0912 HLTA1001 HLTA1002 HLTA1003 HLTA1004 HLTA1005 HLTA1006 HLTA1007 HLTA1008 HLTA1009 HLTA1010 HLTA1011 HLTA1012 HLTB0101 HLTB0102 HLTB0103 HLTB0104 HLTB0105 HLTB0106 HLTB0107 HLTB0108 HLTB0109 HLTB0110 HLTB0111 HLTB0112 HLTB0201 HLTB0202 HLTB0203 HLTB0204 HLTB0205 HLTB0206 HLTB0207 HLTB0208 HLTB0209 HLTB0210 HLTB0211 HLTB0212 HLTB0301 HLTB0302 HLTB0303 HLTB0304 HLTB0305 HLTB0306 HLTB0307 HLTB0308 HLTB0309 HLTB0310 HLTB0311 HLTB0312 HLTB0401 HLTB0402 HLTB0403 HLTB0404 HLTB0405 HLTB0406 HLTB0407 HLTB0408 HLTB0409 HLTB0410 HLTB0411 HLTB0412 HLTB0501 HLTB0502 HLTB0503 HLTB0504 HLTB0505 HLTB0506 HLTB0507 HLTB0508 HLTB0509 HLTB0510 HLTB0511 HLTB0512 HLTB0901 HLTB0902 HLTB0903 HLTB0904 HLTB1001 HLTB1002 HLTB1003 HLTB1004 HLTC0101 HLTC0102 HLTC0103 HLTC0104 HLTC0105 HLTC0106 HLTC0107 HLTC0108 HLTC0109 HLTC0110 HLTC0111 HLTC0112 HLTC0201 HLTC0202 HLTC0203 HLTC0204 HLTC0205 HLTC0206 HLTC0207 HLTC0208 HLTC0209 HLTC0210 HLTC0211 HLTC0212 HLTC0301 HLTC0302 HLTC0303 HLTC0304 HLTC0309 HLTC0310 HLTC0311 HLTC0312 HLTC0401 HLTC0402 HLTC0403 HLTC0404 HLTC0501 HLTC0502 HLTC0503 HLTC0504 HLTC0601 HLTC0602 HLTC0603 HLTC0604 HLTC0617 HLTC0618 HLTC0619 HLTC0620 HLTC0701 HLTC0702 HLTC0703 HLTC0704 HLTC0705 HLTC0706 HLTC0707 HLTC0708 HLTC0709 HLTC0710 HLTC0711 HLTC0712 HLTC0717 HLTC0718 HLTC0719 HLTC0720 HLTC0801 HLTC0802 HLTC0803 HLTC0804 HLTC0805 HLTC0806 HLTC0807 HLTC0808 HLTC0809 HLTC0810 HLTC0811 HLTC0812 HLTC0817 HLTC0818 HLTC0819 HLTC0820 HLTC0901 HLTC0902 HLTC0903 HLTC0904 HLTC0905 HLTC0906 HLTC0907 HLTC0908 HLTC0909 HLTC0910 HLTC0911 HLTC0912 HLTC0917 HLTC0918 HLTC0919 HLTC0920 HLTC1001 HLTC1002 HLTC1003 HLTC1004 HLTC1005 HLTC1006 HLTC1007 HLTC1008 HLTC1009 HLTC1010 HLTC1011 HLTC1012 HLTC1017 HLTC1018 HLTC1019 HLTC1020 HLTD0101 HLTD0102 HLTD0103 HLTD0104 HLTD0105 HLTD0106 HLTD0107 HLTD0108 HLTD0109 HLTD0110 HLTD0111 HLTD0112 HLTD0201 HLTD0202 HLTD0203 HLTD0204 HLTD0205 HLTD0206 HLTD0207 HLTD0208 HLTD0209 HLTD0210 HLTD0211 HLTD0212 HLTD0301 HLTD0302 HLTD0303 HLTD0304 HLTD0305 HLTD0306 HLTD0307 HLTD0308 HLTD0309 HLTD0310 HLTD0311 HLTD0312 HLTD0401 HLTD0402 HLTD0403 HLTD0404 HLTD0405 HLTD0406 HLTD0407 HLTD0408 HLTD0409 HLTD0410 HLTD0411 HLTD0412 HLTD0501 HLTD0502 HLTD0503 HLTD0504 HLTD0505 HLTD0506 HLTD0507 HLTD0508 HLTD0509 HLTD0510 HLTD0511 HLTD0512 HLTD0601 HLTD0602 HLTD0603 HLTD0604 HLTD0605 HLTD0606 HLTD0607 HLTD0608 HLTD0609 HLTD0610 HLTD0611 HLTD0612 HLTD0617 HLTD0618 HLTD0619 HLTD0620 HLTD0701 HLTD0702 HLTD0703 HLTD0704 HLTD0705 HLTD0706 HLTD0707 HLTD0708 HLTD0709 HLTD0710 HLTD0711 HLTD0712 HLTD0717 HLTD0718 HLTD0719 HLTD0720 HLTD0801 HLTD0802 HLTD0803 HLTD0804 HLTD0805 HLTD0806 HLTD0807 HLTD0808 HLTD0809 HLTD0810 HLTD0811 HLTD0812 HLTD0817 HLTD0818 HLTD0819 HLTD0820 HLTD0901 HLTD0902 HLTD0903 HLTD0904 HLTD0905 HLTD0906 HLTD0907 HLTD0908 HLTD0909 HLTD0910 HLTD0911 HLTD0912 HLTD0917 HLTD0918 HLTD0919 HLTD0920 HLTD1001 HLTD1002 HLTD1003 HLTD1004 HLTD1005 HLTD1006 HLTD1007 HLTD1008 HLTD1009 HLTD1010 HLTD1011 HLTD1012 HLTD1017 HLTD1018 HLTD1019 HLTD1020 HLTE0101 HLTE0102 HLTE0103 HLTE0104 HLTE0105 HLTE0106 HLTE0107 HLTE0108 HLTE0109 HLTE0110 HLTE0111 HLTE0112 HLTE0201 HLTE0202 HLTE0203 HLTE0204 HLTE0205 HLTE0206 HLTE0207 HLTE0208 HLTE0209 HLTE0210 HLTE0211 HLTE0212 HLTE0301 HLTE0302 HLTE0303 HLTE0304 HLTE0305 HLTE0306 HLTE0307 HLTE0308 HLTE0309 HLTE0310 HLTE0311 HLTE0312 HLTE0401 HLTE0402 HLTE0403 HLTE0404 HLTE0405 HLTE0406 HLTE0407 HLTE0408 HLTE0409 HLTE0410 HLTE0411 HLTE0412 HLTE0501 HLTE0502 HLTE0503 HLTE0504 HLTE0505 HLTE0506 HLTE0507 HLTE0508 HLTE0509 HLTE0510 HLTE0511 HLTE0512 HLTE0601 HLTE0602 HLTE0603 HLTE0604 HLTE0605 HLTE0606 HLTE0607 HLTE0608 HLTE0609 HLTE0610 HLTE0611 HLTE0612 HLTE0701 HLTE0702 HLTE0703 HLTE0704 HLTE0705 HLTE0706 HLTE0707 HLTE0708 HLTE0709 HLTE0710 HLTE0711 HLTE0712 HLTE0801 HLTE0802 HLTE0803 HLTE0804 HLTE0805 HLTE0806 HLTE0807 HLTE0808 HLTE0809 HLTE0810 HLTE0811 HLTE0812 HLTE0901 HLTE0902 HLTE0903 HLTE0904 HLTE0905 HLTE0906 HLTE0907 HLTE0908 HLTE0909 HLTE0910 HLTE0911 HLTE0912 HLTE1001 HLTE1002 HLTE1003 HLTE1004 HLTE1005 HLTE1006 HLTE1007 HLTE1008 HLTE1009 HLTE1010 HLTE1011 HLTE1012 HLTF0201 HLTF0202 HLTF0203 HLTF0204 HLTF0301 HLTF0302 HLTF0303 HLTF0304 HLTF0401 HLTF0402 HLTF0403 HLTF0404 HLTF0501 HLTF0502 HLTF0503 HLTF0504 HLTF0601 HLTF0602 HLTF0603 HLTF0604 HLTF0701 HLTF0702 HLTF0703 HLTF0704 HLTF0729 HLTF0730 HLTF0731 HLTF0732" -mediumNodes="HLTC0305 HLTC0306 HLTC0307 HLTC0308 HLTC0405 HLTC0406 HLTC0407 HLTC0408 HLTC0409 HLTC0410 HLTC0411 HLTC0412 HLTC0505 HLTC0506 HLTC0507 HLTC0508 HLTC0509 HLTC0510 HLTC0511 HLTC0512 HLTC0605 HLTC0606 HLTC0607 HLTC0608 HLTC0609 HLTC0610 HLTC0611 HLTC0612 HLTF0221 HLTF0222 HLTF0223 HLTF0224 HLTF0225 HLTF0226 HLTF0227 HLTF0228 HLTF0229 HLTF0230 HLTF0231 HLTF0232 HLTF0321 HLTF0322 HLTF0323 HLTF0324 HLTF0325 HLTF0326 HLTF0327 HLTF0328 HLTF0329 HLTF0330 HLTF0331 HLTF0332 HLTF0421 HLTF0422 HLTF0423 HLTF0424 HLTF0425 HLTF0426 HLTF0427 HLTF0428 HLTF0429 HLTF0430 HLTF0431 HLTF0432 HLTF0521 HLTF0522 HLTF0523 HLTF0524 HLTF0525 HLTF0526 HLTF0527 HLTF0528 HLTF0529 HLTF0530 HLTF0531 HLTF0532 HLTF0621 HLTF0622 HLTF0623 HLTF0624 HLTF0625 HLTF0626 HLTF0627 HLTF0628 HLTF0629 HLTF0630 HLTF0631 HLTF0632 HLTF0721 HLTF0722 HLTF0723 HLTF0724 HLTF0725 HLTF0726 HLTF0727 HLTF0728" -fastNodes="HLTA0117 HLTA0118 HLTA0119 HLTA0120 HLTA0121 HLTA0122 HLTA0123 HLTA0124 HLTA0125 HLTA0126 HLTA0127 HLTA0128 HLTA0217 HLTA0218 HLTA0219 HLTA0220 HLTA0221 HLTA0222 HLTA0223 HLTA0224 HLTA0225 HLTA0226 HLTA0227 HLTA0228 HLTA0317 HLTA0318 HLTA0319 HLTA0320 HLTA0321 HLTA0322 HLTA0323 HLTA0324 HLTA0325 HLTA0326 HLTA0327 HLTA0328 HLTA0417 HLTA0418 HLTA0419 HLTA0420 HLTA0421 HLTA0422 HLTA0423 HLTA0424 HLTA0425 HLTA0426 HLTA0427 HLTA0428 HLTA0517 HLTA0518 HLTA0519 HLTA0520 HLTA0521 HLTA0522 HLTA0523 HLTA0524 HLTA0525 HLTA0526 HLTA0527 HLTA0528 HLTA0621 HLTA0622 HLTA0623 HLTA0624 HLTA0625 HLTA0626 HLTA0627 HLTA0628 HLTA0721 HLTA0722 HLTA0723 HLTA0724 HLTA0725 HLTA0726 HLTA0727 HLTA0728 HLTA0821 HLTA0822 HLTA0823 HLTA0824 HLTA0825 HLTA0826 HLTA0827 HLTA0828 HLTA0917 HLTA0918 HLTA0919 HLTA0920 HLTA0921 HLTA0922 HLTA0923 HLTA0924 HLTA0925 HLTA0926 HLTA0927 HLTA0928 HLTA1017 HLTA1018 HLTA1019 HLTA1020 HLTA1021 HLTA1022 HLTA1023 HLTA1024 HLTA1025 HLTA1026 HLTA1027 HLTA1028 HLTB0117 HLTB0118 HLTB0119 HLTB0120 HLTB0121 HLTB0122 HLTB0123 HLTB0124 HLTB0125 HLTB0126 HLTB0127 HLTB0128 HLTB0217 HLTB0218 HLTB0219 HLTB0220 HLTB0221 HLTB0222 HLTB0223 HLTB0224 HLTB0225 HLTB0226 HLTB0227 HLTB0228 HLTB0317 HLTB0318 HLTB0319 HLTB0320 HLTB0321 HLTB0322 HLTB0323 HLTB0324 HLTB0325 HLTB0326 HLTB0327 HLTB0328 HLTB0417 HLTB0418 HLTB0419 HLTB0420 HLTB0421 HLTB0422 HLTB0423 HLTB0424 HLTB0425 HLTB0426 HLTB0427 HLTB0428 HLTB0517 HLTB0518 HLTB0519 HLTB0520 HLTB0521 HLTB0522 HLTB0523 HLTB0524 HLTB0525 HLTB0526 HLTB0527 HLTB0528 HLTB0601 HLTB0602 HLTB0603 HLTB0604 HLTB0605 HLTB0606 HLTB0607 HLTB0608 HLTB0609 HLTB0610 HLTB0611 HLTB0612 HLTB0617 HLTB0618 HLTB0619 HLTB0620 HLTB0621 HLTB0622 HLTB0623 HLTB0624 HLTB0625 HLTB0626 HLTB0627 HLTB0628 HLTB0701 HLTB0702 HLTB0703 HLTB0704 HLTB0705 HLTB0706 HLTB0707 HLTB0708 HLTB0709 HLTB0710 HLTB0711 HLTB0712 HLTB0717 HLTB0718 HLTB0719 HLTB0720 HLTB0721 HLTB0722 HLTB0723 HLTB0724 HLTB0725 HLTB0726 HLTB0727 HLTB0728 HLTB0801 HLTB0802 HLTB0803 HLTB0804 HLTB0805 HLTB0806 HLTB0807 HLTB0808 HLTB0809 HLTB0810 HLTB0811 HLTB0812 HLTB0817 HLTB0818 HLTB0819 HLTB0820 HLTB0821 HLTB0822 HLTB0823 HLTB0824 HLTB0825 HLTB0826 HLTB0827 HLTB0828 HLTB0905 HLTB0906 HLTB0907 HLTB0908 HLTB0909 HLTB0910 HLTB0911 HLTB0912 HLTB0917 HLTB0918 HLTB0919 HLTB0920 HLTB0921 HLTB0922 HLTB0923 HLTB0924 HLTB0925 HLTB0926 HLTB0927 HLTB0928 HLTB1005 HLTB1006 HLTB1007 HLTB1008 HLTB1009 HLTB1010 HLTB1011 HLTB1012 HLTB1017 HLTB1018 HLTB1019 HLTB1020 HLTB1021 HLTB1022 HLTB1023 HLTB1024 HLTB1025 HLTB1026 HLTB1027 HLTB1028 HLTC0117 HLTC0118 HLTC0119 HLTC0120 HLTC0121 HLTC0122 HLTC0123 HLTC0124 HLTC0125 HLTC0126 HLTC0127 HLTC0128 HLTC0217 HLTC0218 HLTC0219 HLTC0220 HLTC0221 HLTC0222 HLTC0223 HLTC0224 HLTC0225 HLTC0226 HLTC0227 HLTC0228 HLTC0317 HLTC0318 HLTC0319 HLTC0320 HLTC0321 HLTC0322 HLTC0323 HLTC0324 HLTC0325 HLTC0326 HLTC0327 HLTC0328 HLTC0417 HLTC0418 HLTC0419 HLTC0420 HLTC0421 HLTC0422 HLTC0423 HLTC0424 HLTC0425 HLTC0426 HLTC0427 HLTC0428 HLTC0517 HLTC0518 HLTC0519 HLTC0520 HLTC0521 HLTC0522 HLTC0523 HLTC0524 HLTC0525 HLTC0526 HLTC0527 HLTC0528 HLTC0621 HLTC0622 HLTC0623 HLTC0624 HLTC0625 HLTC0626 HLTC0627 HLTC0628 HLTC0721 HLTC0722 HLTC0723 HLTC0724 HLTC0725 HLTC0726 HLTC0727 HLTC0728 HLTC0821 HLTC0822 HLTC0823 HLTC0824 HLTC0825 HLTC0826 HLTC0827 HLTC0828 HLTC0921 HLTC0922 HLTC0923 HLTC0924 HLTC0925 HLTC0926 HLTC0927 HLTC0928 HLTC1021 HLTC1022 HLTC1023 HLTC1024 HLTC1025 HLTC1026 HLTC1027 HLTC1028 HLTD0117 HLTD0118 HLTD0119 HLTD0120 HLTD0121 HLTD0122 HLTD0123 HLTD0124 HLTD0125 HLTD0126 HLTD0127 HLTD0128 HLTD0217 HLTD0218 HLTD0219 HLTD0220 HLTD0221 HLTD0222 HLTD0223 HLTD0224 HLTD0225 HLTD0226 HLTD0227 HLTD0228 HLTD0317 HLTD0318 HLTD0319 HLTD0320 HLTD0321 HLTD0322 HLTD0323 HLTD0324 HLTD0325 HLTD0326 HLTD0327 HLTD0328 HLTD0417 HLTD0418 HLTD0419 HLTD0420 HLTD0421 HLTD0422 HLTD0423 HLTD0424 HLTD0425 HLTD0426 HLTD0427 HLTD0428 HLTD0517 HLTD0518 HLTD0519 HLTD0520 HLTD0521 HLTD0522 HLTD0523 HLTD0524 HLTD0525 HLTD0526 HLTD0527 HLTD0528 HLTD0621 HLTD0622 HLTD0623 HLTD0624 HLTD0625 HLTD0626 HLTD0627 HLTD0628 HLTD0721 HLTD0722 HLTD0723 HLTD0724 HLTD0725 HLTD0726 HLTD0727 HLTD0728 HLTD0821 HLTD0822 HLTD0823 HLTD0824 HLTD0825 HLTD0826 HLTD0827 HLTD0828 HLTD0921 HLTD0922 HLTD0923 HLTD0924 HLTD0925 HLTD0926 HLTD0927 HLTD0928 HLTD1021 HLTD1022 HLTD1023 HLTD1024 HLTD1025 HLTD1026 HLTD1027 HLTD1028 HLTE0117 HLTE0118 HLTE0119 HLTE0120 HLTE0121 HLTE0122 HLTE0123 HLTE0124 HLTE0125 HLTE0126 HLTE0127 HLTE0128 HLTE0217 HLTE0218 HLTE0219 HLTE0220 HLTE0221 HLTE0222 HLTE0223 HLTE0224 HLTE0225 HLTE0226 HLTE0227 HLTE0228 HLTE0317 HLTE0318 HLTE0319 HLTE0320 HLTE0321 HLTE0322 HLTE0323 HLTE0324 HLTE0325 HLTE0326 HLTE0327 HLTE0328 HLTE0417 HLTE0418 HLTE0419 HLTE0420 HLTE0421 HLTE0422 HLTE0423 HLTE0424 HLTE0425 HLTE0426 HLTE0427 HLTE0428 HLTE0517 HLTE0518 HLTE0519 HLTE0520 HLTE0521 HLTE0522 HLTE0523 HLTE0524 HLTE0525 HLTE0526 HLTE0527 HLTE0528 HLTE0617 HLTE0618 HLTE0619 HLTE0620 HLTE0621 HLTE0622 HLTE0623 HLTE0624 HLTE0625 HLTE0626 HLTE0627 HLTE0628 HLTE0717 HLTE0718 HLTE0719 HLTE0720 HLTE0721 HLTE0722 HLTE0723 HLTE0724 HLTE0725 HLTE0726 HLTE0727 HLTE0728 HLTE0817 HLTE0818 HLTE0819 HLTE0820 HLTE0821 HLTE0822 HLTE0823 HLTE0824 HLTE0825 HLTE0826 HLTE0827 HLTE0828 HLTE0917 HLTE0918 HLTE0919 HLTE0920 HLTE0921 HLTE0922 HLTE0923 HLTE0924 HLTE0925 HLTE0926 HLTE0927 HLTE0928 HLTE1017 HLTE1018 HLTE1019 HLTE1020 HLTE1021 HLTE1022 HLTE1023 HLTE1024 HLTE1025 HLTE1026 HLTE1027 HLTE1028 HLTF0101 HLTF0102 HLTF0103 HLTF0104 HLTF0105 HLTF0106 HLTF0107 HLTF0108 HLTF0109 HLTF0110 HLTF0111 HLTF0112 HLTF0113 HLTF0114 HLTF0115 HLTF0116 HLTF0117 HLTF0118 HLTF0119 HLTF0120 HLTF0121 HLTF0122 HLTF0123 HLTF0124 HLTF0125 HLTF0126 HLTF0127 HLTF0128 HLTF0129 HLTF0130 HLTF0131 HLTF0132 HLTF0801 HLTF0802 HLTF0803 HLTF0804 HLTF0805 HLTF0806 HLTF0807 HLTF0808 HLTF0809 HLTF0810 HLTF0811 HLTF0812 HLTF0813 HLTF0814 HLTF0815 HLTF0816 HLTF0817 HLTF0818 HLTF0819 HLTF0820 HLTF0821 HLTF0822 HLTF0823 HLTF0824 HLTF0825 HLTF0826 HLTF0827 HLTF0828 HLTF0829 HLTF0830 HLTF0831 HLTF0832 HLTF0901 HLTF0902 HLTF0903 HLTF0904 HLTF0905 HLTF0906 HLTF0907 HLTF0908 HLTF0909 HLTF0910 HLTF0911 HLTF0912 HLTF0913 HLTF0914 HLTF0915 HLTF0916 HLTF0917 HLTF0918 HLTF0919 HLTF0920 HLTF0921 HLTF0922 HLTF0923 HLTF0924 HLTF0925 HLTF0926 HLTF0927 HLTF0928 HLTF0929 HLTF0930 HLTF0931 HLTF0932 HLTF1001 HLTF1002 HLTF1003 HLTF1004 HLTF1005 HLTF1006 HLTF1007 HLTF1008 HLTF1009 HLTF1010 HLTF1011 HLTF1012 HLTF1013 HLTF1014 HLTF1015 HLTF1016 HLTF1017 HLTF1018 HLTF1019 HLTF1020 HLTF1021 HLTF1022 HLTF1023 HLTF1024 HLTF1025 HLTF1026 HLTF1027 HLTF1028 HLTF1029 HLTF1030" -fasterNodes="HLTA0113 HLTA0114 HLTA0115 HLTA0116 HLTA0213 HLTA0214 HLTA0215 HLTA0216 HLTA0313 HLTA0314 HLTA0315 HLTA0316 HLTA0413 HLTA0414 HLTA0415 HLTA0416 HLTA0513 HLTA0514 HLTA0515 HLTA0516 HLTA0613 HLTA0614 HLTA0615 HLTA0616 HLTA0713 HLTA0714 HLTA0715 HLTA0716 HLTA0813 HLTA0814 HLTA0815 HLTA0816 HLTA0913 HLTA0914 HLTA0915 HLTA0916 HLTA1013 HLTA1014 HLTA1015 HLTA1016 HLTB0113 HLTB0114 HLTB0115 HLTB0116 HLTB0213 HLTB0214 HLTB0215 HLTB0216 HLTB0313 HLTB0314 HLTB0315 HLTB0316 HLTB0413 HLTB0414 HLTB0415 HLTB0416 HLTB0513 HLTB0514 HLTB0515 HLTB0516 HLTB0613 HLTB0614 HLTB0615 HLTB0616 HLTB0713 HLTB0714 HLTB0715 HLTB0716 HLTB0813 HLTB0814 HLTB0815 HLTB0816 HLTB0913 HLTB0914 HLTB0915 HLTB0916 HLTB1013 HLTB1014 HLTB1015 HLTB1016 HLTC0113 HLTC0114 HLTC0115 HLTC0116 HLTC0213 HLTC0214 HLTC0215 HLTC0216 HLTC0313 HLTC0314 HLTC0315 HLTC0316 HLTC0413 HLTC0414 HLTC0415 HLTC0416 HLTC0513 HLTC0514 HLTC0515 HLTC0516 HLTC0613 HLTC0614 HLTC0615 HLTC0616 HLTC0713 HLTC0714 HLTC0715 HLTC0716 HLTC0813 HLTC0814 HLTC0815 HLTC0816 HLTC0913 HLTC0914 HLTC0915 HLTC0916 HLTC1013 HLTC1014 HLTC1015 HLTC1016 HLTD0113 HLTD0114 HLTD0115 HLTD0116 HLTD0213 HLTD0214 HLTD0215 HLTD0216 HLTD0313 HLTD0314 HLTD0315 HLTD0316 HLTD0413 HLTD0414 HLTD0415 HLTD0416 HLTD0513 HLTD0514 HLTD0515 HLTD0516 HLTD0613 HLTD0614 HLTD0615 HLTD0616 HLTD0713 HLTD0714 HLTD0715 HLTD0716 HLTD0813 HLTD0814 HLTD0815 HLTD0816 HLTD0913 HLTD0914 HLTD0915 HLTD0916 HLTD1013 HLTD1014 HLTD1015 HLTD1016 HLTE0113 HLTE0114 HLTE0115 HLTE0116 HLTE0213 HLTE0214 HLTE0215 HLTE0216 HLTE0313 HLTE0314 HLTE0315 HLTE0316 HLTE0413 HLTE0414 HLTE0415 HLTE0416 HLTE0513 HLTE0514 HLTE0515 HLTE0516 HLTE0613 HLTE0614 HLTE0615 HLTE0616 HLTE0713 HLTE0714 HLTE0715 HLTE0716 HLTE0813 HLTE0814 HLTE0815 HLTE0816 HLTE0913 HLTE0914 HLTE0915 HLTE0916 HLTE1013 HLTE1014 HLTE1015 HLTE1016 HLTF0205 HLTF0206 HLTF0207 HLTF0208 HLTF0209 HLTF0210 HLTF0211 HLTF0212 HLTF0213 HLTF0214 HLTF0215 HLTF0216 HLTF0217 HLTF0218 HLTF0219 HLTF0220 HLTF0305 HLTF0306 HLTF0307 HLTF0308 HLTF0309 HLTF0310 HLTF0311 HLTF0312 HLTF0313 HLTF0314 HLTF0315 HLTF0316 HLTF0317 HLTF0318 HLTF0319 HLTF0320 HLTF0405 HLTF0406 HLTF0407 HLTF0408 HLTF0409 HLTF0410 HLTF0411 HLTF0412 HLTF0413 HLTF0414 HLTF0415 HLTF0416 HLTF0417 HLTF0418 HLTF0419 HLTF0420 HLTF0505 HLTF0506 HLTF0507 HLTF0508 HLTF0509 HLTF0510 HLTF0511 HLTF0512 HLTF0513 HLTF0514 HLTF0515 HLTF0516 HLTF0517 HLTF0518 HLTF0519 HLTF0520 HLTF0605 HLTF0606 HLTF0607 HLTF0608 HLTF0609 HLTF0610 HLTF0611 HLTF0612 HLTF0613 HLTF0614 HLTF0615 HLTF0616 HLTF0617 HLTF0618 HLTF0619 HLTF0620 HLTF0705 HLTF0706 HLTF0707 HLTF0708 HLTF0709 HLTF0710 HLTF0711 HLTF0712 HLTF0713 HLTF0714 HLTF0715 HLTF0716 HLTF0717 HLTF0718 HLTF0719 HLTF0720" -ninstnod=[1,2,4,6,8,10,12,14,16,18,20,22,24,28,32]#,36,40,44,48] -tintv=[] -t1=time.mktime(time.strptime('24-09-2016 13:50:00','%d-%m-%Y %H:%M:%S')) -t2=time.mktime(time.strptime('24-09-2016 13:51:00','%d-%m-%Y %H:%M:%S')) -tintv.append(Interval(t1,t2)) -tintv.append(Interval(time.mktime(time.strptime('24-09-2016 13:53:00','%d-%m-%Y %H:%M:%S')), - time.mktime(time.strptime('24-09-2016 13:59:00','%d-%m-%Y %H:%M:%S')))) -tintv.append(Interval(time.mktime(time.strptime('24-09-2016 14:01:00','%d-%m-%Y %H:%M:%S')), - time.mktime(time.strptime('24-09-2016 14:04:00','%d-%m-%Y %H:%M:%S')))) -tintv.append(Interval(time.mktime(time.strptime('24-09-2016 14:06:00','%d-%m-%Y %H:%M:%S')), - time.mktime(time.strptime('24-09-2016 14:12:00','%d-%m-%Y %H:%M:%S')))) -tintv.append(Interval(time.mktime(time.strptime('24-09-2016 14:14:00','%d-%m-%Y %H:%M:%S')), - time.mktime(time.strptime('24-09-2016 14:19:00','%d-%m-%Y %H:%M:%S')))) -tintv.append(Interval(time.mktime(time.strptime('24-09-2016 14:21:00','%d-%m-%Y %H:%M:%S')), - time.mktime(time.strptime('24-09-2016 14:26:00','%d-%m-%Y %H:%M:%S')))) -tintv.append(Interval(time.mktime(time.strptime('24-09-2016 14:28:00','%d-%m-%Y %H:%M:%S')), - time.mktime(time.strptime('24-09-2016 14:41:00','%d-%m-%Y %H:%M:%S')))) -tintv.append(Interval(time.mktime(time.strptime('24-09-2016 14:43:00','%d-%m-%Y %H:%M:%S')), - time.mktime(time.strptime('24-09-2016 14:52:00','%d-%m-%Y %H:%M:%S')))) -tintv.append(Interval(time.mktime(time.strptime('24-09-2016 14:54:00','%d-%m-%Y %H:%M:%S')), - time.mktime(time.strptime('24-09-2016 15:08:00','%d-%m-%Y %H:%M:%S')))) -tintv.append(Interval(time.mktime(time.strptime('24-09-2016 15:10:00','%d-%m-%Y %H:%M:%S')), - time.mktime(time.strptime('24-09-2016 15:17:00','%d-%m-%Y %H:%M:%S')))) -tintv.append(Interval(time.mktime(time.strptime('24-09-2016 15:19:00','%d-%m-%Y %H:%M:%S')), - time.mktime(time.strptime('24-09-2016 15:32:00','%d-%m-%Y %H:%M:%S')))) -tintv.append(Interval(time.mktime(time.strptime('24-09-2016 15:34:00','%d-%m-%Y %H:%M:%S')), - time.mktime(time.strptime('24-09-2016 15:43:00','%d-%m-%Y %H:%M:%S')))) -tintv.append(Interval(time.mktime(time.strptime('24-09-2016 15:45:00','%d-%m-%Y %H:%M:%S')), - time.mktime(time.strptime('24-09-2016 15:56:00','%d-%m-%Y %H:%M:%S')))) -tintv.append(Interval(time.mktime(time.strptime('24-09-2016 15:58:00','%d-%m-%Y %H:%M:%S')), - time.mktime(time.strptime('24-09-2016 16:08:00','%d-%m-%Y %H:%M:%S')))) -tintv.append(Interval(time.mktime(time.strptime('24-09-2016 16:10:00','%d-%m-%Y %H:%M:%S')), - time.mktime(time.strptime('24-09-2016 16:31:00','%d-%m-%Y %H:%M:%S')))) -tintv.append(Interval(time.mktime(time.strptime('24-09-2016 16:33:00','%d-%m-%Y %H:%M:%S')), - time.mktime(time.strptime('24-09-2016 17:05:00','%d-%m-%Y %H:%M:%S')))) -tintv.append(Interval(time.mktime(time.strptime('24-09-2016 17:07:00','%d-%m-%Y %H:%M:%S')), - time.mktime(time.strptime('24-09-2016 17:23:00','%d-%m-%Y %H:%M:%S')))) -tintv.append(Interval(time.mktime(time.strptime('24-09-2016 17:25:00','%d-%m-%Y %H:%M:%S')), - time.mktime(time.strptime('24-09-2016 17:53:00','%d-%m-%Y %H:%M:%S')))) -tintv.append(Interval(time.mktime(time.strptime('24-09-2016 17:55:00','%d-%m-%Y %H:%M:%S')), - time.mktime(time.strptime('24-09-2016 18:05:00','%d-%m-%Y %H:%M:%S')))) - - -# ,36,40,44,48] -# ninst = [] -# for i in ninstnod: -# ninst.append(i*335.0) -# ninst.append(11300.0) -# ninst.append(11500) -# ninst.append(12000) -# mintv = [] -mdict=dict() -# for i in ninst: -# mintv.append(Interval(i*0.95,i*1.05)) -# for i in mintv: -# mdict[i.ID()] = [] -NexNodes=nexNodes.split(" ") -for i in NexNodes: - slowNodes=slowNodes.replace(i+" ","") -SlowNodes=NodeType('Slow',ninstnod+[32,32,32,32]) -SlowNodes.Nodes=slowNodes.split(" ") -MediumNodes=NodeType('Medium',ninstnod+[36,36,36,36]) -MediumNodes.Nodes=mediumNodes.split(" ") -FastNodes=NodeType('Fast',ninstnod+[36,40,40,40]) -FastNodes.Nodes=fastNodes.split(" ") -FasterNodes=NodeType('Faster',ninstnod+[36,40,44,48]) -FasterNodes.Nodes=fasterNodes.split(" ") -nodrates=[] -for farm in ["A","B","C","D","E","F"]: - fnam = "/home/beat/InputRates/input_"+farm+".srt" - f = open(fnam,"r") - l = f.readlines() - f.close() - nodrates=nodrates+l -f = open("/home/beat/InputRates/Moore2s.srt","r") -moores=[] -moores=f.readlines() -moores.sort( key=lambda x:float(x.split(",")[2])) -nodrates.sort() -for i in range(len(nodrates)): - nodrates[i] = nodrates[i].replace("LBECSDF:LbDFFarmNode_",'') - nodrates[i] = nodrates[i].replace("_2.InputRate",'') - if SlowNodes.Nodein(Node(nodrates[i])): - SlowNodes.Records.append(nodrates[i]) - elif MediumNodes.Nodein(Node(nodrates[i])): - MediumNodes.Records.append(nodrates[i]) - elif FastNodes.Nodein(Node(nodrates[i])): - FastNodes.Records.append(nodrates[i]) - elif FasterNodes.Nodein(Node(nodrates[i])): - FasterNodes.Records.append(nodrates[i]) - -# for i in range(len(moores)): -# moores[i] = moores[i].replace('\n','') -# for j in tintv: -# tst=TStamp(moores[i].split(',')[0]) -# # tst=tst[0:tst.find('.')] -# tflo = time.mktime(time.strptime(tst,'%d-%m-%Y %H:%M:%S')) -# if j.In(tflo): -# if j.ID() not in mdict.keys(): -# mdict[j.ID()] = [] -# mdict[j.ID()].append(moores[i]) -# for i in mdict.keys(): -# mdict[i].sort() -# print '============' -# print i -# for j in mdict[i]: -# print j+'\n' -for i in range(len(nodrates)): - nodrates[i] = nodrates[i].replace('\n','') -SlowNodes.analyse() -for i in range(len(SlowNodes.stats)): - print(SlowNodes.ninsts[i],SlowNodes.stats[i].nents,SlowNodes.stats[i].avg,SlowNodes.stats[i].rms) -MediumNodes.analyse() -for i in range(len(MediumNodes.stats)): - print(MediumNodes.ninsts[i],MediumNodes.stats[i].nents,MediumNodes.stats[i].avg,MediumNodes.stats[i].rms) -FastNodes.analyse() -for i in range(len(FastNodes.stats)): - print(FastNodes.ninsts[i],FastNodes.stats[i].nents,FastNodes.stats[i].avg,FastNodes.stats[i].rms) -FasterNodes.analyse() -for i in range(len(FasterNodes.stats)): - print(FasterNodes.ninsts[i],FasterNodes.stats[i].nents,FasterNodes.stats[i].avg,FasterNodes.stats[i].rms) - diff --git a/Online/FarmConfig/job/L0App.sh b/Online/FarmConfig/job/L0App.sh deleted file mode 100755 index 726c9fcd3c0689f0c1fa2c0f5cc6fc262f841e4a..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/L0App.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -# ========================================================================= -# -# Default script to start the event reader task on the HLT farm -# -# Author F.Dordei -# Version: 1.0 -# Date: 20/05/2013 -# -# ========================================================================= -# -export CMTCONFIG=x86_64-slc6-gcc49-opt; -export DAQ_INHIBIT_FINALIZE=ON; -export HN=`hostname -s | tr a-z A-Z`; -/group/hlt/MOORE/${MOOREONLINE_VERSION}/InstallArea/runL0Online_EFF.sh ${DIM_DNS_NODE} ${PARTITION_NAME} ${NBOFSLAVES}; diff --git a/Online/FarmConfig/job/L0MEPInit.sh b/Online/FarmConfig/job/L0MEPInit.sh deleted file mode 100755 index f8994bd742c4ddf43fc74311c24317b015b8b7cc..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/L0MEPInit.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -# ========================================================================= -# -# Default script to start the buffer manager on the HLT farm worker node -# -# Author M.Frank -# Version: 1.0 -# Date: 20/05/2013 -# -# ========================================================================= -# -exec -a ${UTGID} ${Class0_task} -opt=../options/Daemon.opts -main=../options/${TASK_TYPE}.opts diff --git a/Online/FarmConfig/job/L0Reader.sh b/Online/FarmConfig/job/L0Reader.sh deleted file mode 100755 index 7764029840c3ae70b1146d5901b82148a2b8afdd..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/L0Reader.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -# -NODE=`hostname -s | tr a-z A-Z`; -export NODE_OPTIONS=${DYNAMIC_OPTS}/Nodes/${NODE}_TriggerInfo.opts; -export GO_SERVICE_NAME=${PARTITION_NAME}_${NODE}/Trigger; -##echo "[error] Go service name is: ${GO_SERVICE_NAME}"; -exec -a ${UTGID} ${Class2_task} -opts=../options/${TASK_TYPE}.opts diff --git a/Online/FarmConfig/job/L0Sender.sh b/Online/FarmConfig/job/L0Sender.sh deleted file mode 100755 index 3b6a692c8b40c0f933723cd57204ddb43df65963..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/L0Sender.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -# -export TAN_PORT=YES; -export TAN_NODE=${DATAINTERFACE}; -echo [DEBUG] SUBFARM_OPTIONS: ${SUBFARM_OPTIONS}; -###exec -a ${UTGID} ${Class2_task} -opts=../options/${TASK_TYPE}.opts -exec -a ${UTGID} $gaudi_task -tasktype=LHCb::Class2Task -main=../options/Hlt2Main.opts -opts=../options/${TASK_TYPE}.opts diff --git a/Online/FarmConfig/job/MEPInit.sh b/Online/FarmConfig/job/MEPInit.sh deleted file mode 100755 index a5fa61588e85fb33b77d8121040314f6ffd40601..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/MEPInit.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# ========================================================================= -# -# Default script to start the buffer manager on the HLT farm worker node -# -# Author M.Frank -# Version: 1.0 -# Date: 20/05/2013 -# -# ========================================================================= -exec -a ${UTGID} ${DATAFLOW_task} -class=Class0 -opts=../options/${TASK_TYPE}.opts diff --git a/Online/FarmConfig/job/MEPInitCalib.sh b/Online/FarmConfig/job/MEPInitCalib.sh deleted file mode 100755 index 8a2ca93cb20fda7a4f5c81bdff079ff6a5555c37..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/MEPInitCalib.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -# ========================================================================= -# -# Default script to start the buffer manager on the HLT farm worker node -# -# Author M.Frank -# Version: 1.0 -# Date: 20/05/2013 -# -# ========================================================================= -# -exec -a ${UTGID} ${DATAFLOW_task} -class=Class0 -opts=../options/${TASK_TYPE}.opts; diff --git a/Online/FarmConfig/job/MEPInjector.sh b/Online/FarmConfig/job/MEPInjector.sh deleted file mode 100755 index c9b583f0efc780451c7a58ffed7499a9865f28d4..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/MEPInjector.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -export UTGID=${1}; -. /group/online/dataflow/scripts/preamble.sh -# -exec -a ${UTGID} GaudiOnlineExe.exe \ - libGaudiOnline.so OnlineTask -msgsvc=LHCb::FmcMessageSvc \ - -tasktype=LHCb::Class1Task \ - -main=${GAUDIONLINEROOT}/options/Main.opts \ - -opt=${FARMCONFIGROOT}/options/MEPInjector.opts; diff --git a/Online/FarmConfig/job/MEPInjector_ReaderSvc.sh b/Online/FarmConfig/job/MEPInjector_ReaderSvc.sh deleted file mode 100755 index 6fc279935f42eb386fe6d32fde3bedf25afe636d..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/MEPInjector_ReaderSvc.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -export UTGID=${1}; -. /group/online/dataflow/scripts/preamble.sh; -export HOST=$(hostname --short | awk '{ print toupper($1) }'); -export READER_OPTS=`python -c "s='${UTGID}';print 'MEPInjector_'+s[s.find('_')+1:s.rfind('_')]+'.opts'"`; -# -echo "+++ Reader options:${READER_OPTS}"; -exec -a ${UTGID} ${gaudi_exe} -tasktype=LHCb::Class2Task \ - -main=${GAUDIONLINEROOT}/options/Main.opts \ - -opt=${FARMCONFIGROOT}/options/${READER_OPTS}; diff --git a/Online/FarmConfig/job/MEPrx.sh b/Online/FarmConfig/job/MEPrx.sh deleted file mode 100755 index 5fde8cbfe51074867fe9b330eb83a974d561713e..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/MEPrx.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -# ========================================================================= -# -# Default script to start the event reader task on the HLT farm -# -# Author M.Frank -# Version: 1.0 -# Date: 20/05/2013 -# -# ========================================================================= -export IP_DATAINTERFACE=`python -c "import socket;print socket.gethostbyname(socket.gethostname().split('.')[0]+'-d1')"` -export TELL1BOARDS=${DYNAMIC_OPTS}/${PARTITION_NAME}_Tell1Boards.opts; -exec -a ${UTGID} ${DATAFLOW_task} -class=Class2 -opts=../options/${TASK_TYPE}.opts diff --git a/Online/FarmConfig/job/MEPrxCalib.sh b/Online/FarmConfig/job/MEPrxCalib.sh deleted file mode 100755 index 9a42411332c1710b04ecbb5b64f2869f675edbf4..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/MEPrxCalib.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -# ========================================================================= -# -# Default script to start the event reader task on the HLT farm -# -# Author M.Frank -# Version: 1.0 -# Date: 20/05/2013 -# -# ========================================================================= -# -export IP_DATAINTERFACE=`python -c "import socket;print socket.gethostbyname(socket.gethostname().split('.')[0]+'-d1')"` -export TELL1BOARDS=${DYNAMIC_OPTS}/${PARTITION_NAME}_Tell1Boards.opts; -exec -a ${UTGID} ${DATAFLOW_task} -class=Class2 -opts=../options/${TASK_TYPE}.opts diff --git a/Online/FarmConfig/job/MEPrxNZS.sh b/Online/FarmConfig/job/MEPrxNZS.sh deleted file mode 100755 index c15b39b3648751c6db240f9805f54360f91919c1..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/MEPrxNZS.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -# ========================================================================= -# -# Default script to start the event reader task on the HLT farm -# -# Author M.Frank -# Version: 1.0 -# Date: 20/05/2013 -# -# ========================================================================= -# -export IP_DATAINTERFACE=`python -c "import socket;print socket.gethostbyname(socket.gethostname().split('.')[0]+'-d1')"` -export TELL1BOARDS=${DYNAMIC_OPTS}/${PARTITION_NAME}_Tell1Boards.opts; -exec -a ${UTGID} ${Class2_task} -opts=../options/${TASK_TYPE}.opts diff --git a/Online/FarmConfig/job/MFPGen.sh b/Online/FarmConfig/job/MFPGen.sh index dfe4b380f8296d2f031adf24f234488d3b7b48f6..2655c0ed4ab674271fda5585c440cbcb9674c1d3 100755 --- a/Online/FarmConfig/job/MFPGen.sh +++ b/Online/FarmConfig/job/MFPGen.sh @@ -9,7 +9,9 @@ # # ========================================================================= # -. /group/online/dataflow/EventBuilder/EventBuilderRelease/setup.x86_64-centos7-gcc9-opt.vars; +# . /group/online/dataflow/EventBuilder/EventBuilderRelease/setup.x86_64-centos7-gcc9-opt.vars; +. /group/online/dataflow/EventBuilder/EventBuilderRelease/setup.x86_64_v2-centos7-gcc10-opt.vars; +#. /group/online/dataflow/EventBuilder/EventBuilderRelease/setup.${CMTCONFIG}.vars; cd ${FARMCONFIGROOT}/job; # `dataflow_task Class1` -opts=../../EventBuilding/options/${TASK_TYPE}.opts ${AUTO_STARTUP} ${DEBUG_STARTUP}; diff --git a/Online/FarmConfig/job/MSFDefaultTask.sh b/Online/FarmConfig/job/MSFDefaultTask.sh deleted file mode 100755 index 08e6a8484a517521ee002d738e14c63117d45353..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/MSFDefaultTask.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -. /home/frankm/cmtuser/OnlineDev_v5r31/Online/Dataflow/scripts/DefaultTask.sh; diff --git a/Online/FarmConfig/job/MSFWriter.sh b/Online/FarmConfig/job/MSFWriter.sh deleted file mode 100755 index d10136f3e73b9e15a1e53fc347c73965db6f6dc8..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/MSFWriter.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -exec -a ${UTGID} ${DATAFLOW_task} -class=Class1 -opts=${DATAFLOWROOT}/options/MSFWriter.opts $*; diff --git a/Online/FarmConfig/job/MonAdderOpts.py b/Online/FarmConfig/job/MonAdderOpts.py deleted file mode 100755 index 1115eb4c0eede5a6731f99ca4ce0c417bbac13a6..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/MonAdderOpts.py +++ /dev/null @@ -1,87 +0,0 @@ -from __future__ import print_function -from builtins import range -import sys -import OnlineEnvBase -from xml.dom import minidom - -def TaskListfromFile(arch, tasklist): - f = open(arch,"r") - t = f.readlines() - f.close() - for i in range(len(t)): - t[i] = t[i].replace('\n','') - tasklist.append(t[i]) -def TaskListfromArch(arch, tasklist): - xmldoc = minidom.parse(arch) - itemlist = xmldoc.getElementsByTagName('task') -# tasklist = [] - for s in itemlist: - tasklist.append(s.attributes['name'].value) -def openFile(ofile): - f = open(ofile,'w') - return f -def writePreamble(f): - f.write("""#include "$INFO_OPTIONS" -ApplicationMgr.EventLoop = "LHCb::OnlineRunable/EmptyEventLoop"; -ApplicationMgr.Runable = "LHCb::OnlineRunable/Runable"; -ApplicationMgr.HistogramPersistency = "NONE"; -ApplicationMgr.EvtSel = "NONE"; - -Runable.Wait = 3; // 1 of running as daemon (Class1 task) - -MessageSvc.fifoPath = "$LOGFIFO"; -MessageSvc.OutputLevel = @OnlineEnv.OutputLevel; -MonitorSvc.OutputLevel = @OnlineEnv.OutputLevel; -HistogramPersistencySvc.Warnings = false; -""") -def OptionsfromTasks(tasklist,f): - histsvc = [] - cntsvc = [] - for s in tasklist: - if 'NodeAdder' in s: - continue - f.write("ApplicationMgr.ExtSvc += {\"EvtsPub/"+s+"\"};\n") - f.write(s+".myName = \""+s+"\";\n") - f.write(s+".PartitionName = @OnlineEnv.PartitionName;\n") - f.write(s+".TaskPattern = \"" + s + "(.*)\";\n") - f.write(s+".ServicePattern = \"MON_"+s+"/Counter/\";\n") - f.write(s+".AdderClass = \"Counter\";\n") - f.write(s+".InDNS = \"mona08\";\n") - f.write(s+".OutDNS = \"ecs03\";\n") - f.write("\n") - f.write("\n"); - -def CalibOptionsfromTasks(tasklist,f): - histsvc = [] - cntsvc = [] - for s in tasklist: - if 'NodeAdder' in s: - continue - f.write("ApplicationMgr.ExtSvc += {\"EvtsPub/"+s+"\"};\n") - f.write(s+".myName = \""+s+"\";\n") - f.write(s+".PartitionName = @OnlineEnv.PartitionName;\n") - f.write(s+".TaskPattern = \"CalibHistos_0\";\n") - f.write(s+".ServicePattern = \"MON_(.*)"+s+"/Counter/\";\n") - f.write(s+".AdderClass = \"Counter\";\n") - f.write(s+".InDNS = \"mona08\";\n") - f.write(s+".OutDNS = \"ecs03\";\n") - f.write("\n") - f.write("\n"); - - -tasklist = [] -part = OnlineEnvBase.PartitionName -arch ="/group/online/dataflow/options/"+part+"/MonitoringTasks.txt" -TaskListfromFile(arch, tasklist) -print(tasklist) -if len(sys.argv) >= 2: - ofile = sys.argv[1] -else: - ofile = "/tmp/AdderOptions.opts" -f=openFile(ofile) -writePreamble(f) -OptionsfromTasks(tasklist,f) -tasklist = [] -arch = "/group/online/dataflow/architectures/lbDataflowArch_Calib.xml" -TaskListfromArch(arch,tasklist) -CalibOptionsfromTasks(tasklist,f) diff --git a/Online/FarmConfig/job/Moore2MonTest.sh b/Online/FarmConfig/job/Moore2MonTest.sh deleted file mode 100644 index 29acbc8b54a7e1995fa21c9ed589a38c71a44b4f..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/Moore2MonTest.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# ========================================================================= -# -# Default script to start the event reader task on the HLT farm -# -# Author M.Frank -# Version: 1.0 -# Date: 20/05/2013 -# -# ========================================================================= -# -if test "`uname -a | grep \".el6\"`" != ""; # SLC6 -then - export CMTCONFIG=x86_64-slc6-gcc62-opt; -elif test "`uname -a | grep el7`" != ""; # SLC7 (Centos 7) -then - export CMTCONFIG=x86_64-centos7-gcc62-opt -fi; -export DAQ_INHIBIT_FINALIZE=ON; -export HN=`hostname -s | tr a-z A-Z`; -if [ "${PARTITION_NAME}" == "LHCb1" ]; then - . /group/hlt/MOORE/${MOOREONLINE_VERSION}/InstallArea/runMooreHlt2Online_EFF.sh ${DIM_DNS_NODE} ${PARTITION_NAME} ${NBOFSLAVES}; -else -if test -f "/group/online/dataflow/options/LHCb2/Nodes/${HN}_TriggerInfo.py"; -then - export PYTHONPATH=/group/online/dataflow/options/LHCb2/Nodes; - unset MOOREONLINE_VERSION; - export MOOREONLINE_VERSION=`python -c "import ${HN}_TriggerInfo as H; print H.MooreOnlineVersion"`; - export MONTEST=1 - ### export CMTCONFIG=x86_64-slc6-gcc48-dbg; - ### source ${FARMCONFIGROOT}/job/runMooreHlt2Online_EFF.sh ${DIM_DNS_NODE} ${PARTITION_NAME} ${NBOFSLAVES}; - . /group/hlt/MOORE/${MOOREONLINE_VERSION}/InstallArea/runMooreHlt2Online_EFF.sh ${DIM_DNS_NODE} ${PARTITION_NAME} ${NBOFSLAVES}; -else - echo "[ERROR] Cannot determine MOOREONLINE_VERSION. No file: /group/online/dataflow/options/LHCb2/Nodes/${HN}_TriggerInfo.py"; -fi; -fi; diff --git a/Online/FarmConfig/job/Muon.py b/Online/FarmConfig/job/Muon.py deleted file mode 100755 index 30aa34e59d1b07291c91c3706d1cb76b7ec66e93..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/Muon.py +++ /dev/null @@ -1,25 +0,0 @@ -from builtins import range -import sys -import os -import Criteria -import time -import re -Crits=Criteria.Criteria() -Crits.__init__() -Crits.keepRuns=list(range(156916,156923+1))+list(range(173905,174056+1))+list(range(174362,174380+1))+list(range(174362,174380 +1))+list(range(18704,18706+1))+list(range(186647,186656 +1))+list(range(192228,192237 +1)) +list(range(192715,192740 +1)) -Crits.addTimeInterval([Criteria.t("1 Jan 2018"),Criteria.t("31 Dec 2018")]) -# Crits.addTimeInterval([Criteria.t("1 Oct 2016"),Criteria.t("1 Nov 2016")]) -# Crits.keepRuns=range(184000,185700) -# Crits.keepRuns.extend(range(174534 , 177133 )) -# Crits.keepRuns.extend(range(182725 , 185611)) -#Crits.FileRegs.append(re.compile("(.*)/Kali(.*).dst",re.I)) -# Crits.addTimeInterval([0,time.mktime(time.strptime("1 Jul 2017","%d %b %Y"))]) -# Crits.addTimeInterval([time.time()-1*86400,time.time()+3*86400]) -# Crits.keepRuns=range(193252, 193279) -# Crits.keepRuns.extend(range(193590 , 193631 )) -# Crits.keepRuns.extend(range(195416 , 195460 )) -# Crits.keepRuns.extend(range(196009 , 196087 )) -# Crits.keepRuns.extend(range(196718,196759 )) -# Crits.keepRuns.extend(range(197420, 197447 )) -# Crits.keepRuns.extend(range(198526,198506 )) - diff --git a/Online/FarmConfig/job/OdinCheck.sh b/Online/FarmConfig/job/OdinCheck.sh deleted file mode 100755 index 0bb40aefdad3904b1261e7e73902ec46a2223ed7..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/OdinCheck.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -# ========================================================================= -# -# Default script to start a task on a farm node -# -# Author M.Frank -# Version: 1.0 -# Date: 20/05/2013 -# -# ========================================================================= -# -exec -a ${UTGID} ${Class2_task} -opts=../options/${TASK_TYPE}.opts -auto diff --git a/Online/FarmConfig/job/OverflowReader.sh b/Online/FarmConfig/job/OverflowReader.sh deleted file mode 100755 index 91bab5ba4b2c8b59cdb6add5f56eb53e42874160..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/OverflowReader.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -# ========================================================================= -# -# Default script to start the event reader task on the HLT farm -# -# Author M.Frank -# Version: 1.0 -# Date: 20/05/2013 -# -# ========================================================================= -# -export PYTHONPATH=${HOME}/data:${PYTHONPATH}; -exec -a ${UTGID} ${Class2_task} -opts=../options/OverflowReader.opts diff --git a/Online/FarmConfig/job/PTHiMu.sh b/Online/FarmConfig/job/PTHiMu.sh deleted file mode 100644 index 73b00a2019fab7aa566fc400f5ac688df742bc59..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/PTHiMu.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -# ========================================================================= -# -# Default script to start the passthrough process on a farm node. -# -# Author M.Frank -# Version: 1.0 -# Date: 20/05/2013 -# -# ========================================================================= -# -export ONLINETASKS=/group/online/dataflow/templates -export PARTITIONOPTS=/group/online/dataflow/options/${PARTNAME}/${PARTNAME}_Info.opts -export CHECKPOINT_SETUP_OPTIONS=${FARMCONFIGROOT}/options/Checkpoint.opts; -export CHECKPOINT_RESTART_OPTIONS=${FARMCONFIGROOT}/options/CheckpointRestart.opts; - -OPTIONS=-opts=../options/${TASK_TYPE}.opts; - -if test "${TAE_PROCESSING}" = "TAE"; -then - OPTIONS=-opts=../options/${TASK_TYPE}_TAE.opts; -fi; -# -export PYTHONPATH=${FARMCONFIGROOT}/job:${PYTHONPATH}; -echo `python ${FARMCONFIGROOT}/job/ConfigureCheckpoint.py -r ${RUNINFO} -s` | tr ";" ";\n"; -eval `python ${FARMCONFIGROOT}/job/ConfigureCheckpoint.py -r ${RUNINFO} -s`; -if test "${APP_STARTUP_OPTS}" = "-restore"; ## RunInfo flag=2 - then - echo "+++ [INFO] ${ONLINE_PROJECT_ROOT} ==> ${RESTORE_CMD}"; - mkdir -p /tmp/Commands; - python -c "import ConfigureFromCheckpoint" > /tmp/Commands/$$.cmds; - ${RESTORE_CMD} < /tmp/Commands/$$.cmds; - #eval "python -c \"import ConfigureFromCheckpoint\" | ${RESTORE_CMD}"; -else - echo "+++ [INFO] ${ONLINE_PROJECT_ROOT} ==> exec -a ${UTGID} ${Checkpoint_task} ${OPTIONS}"; -# HH=`hostname -s | tr a-z A-Z`; -# if test "${HH}" = "HLTA0328"; then -# echo "+++ [INFO] Executing modified online version from frankm."; -# . /home/frankm/cmtuser/OnlineDev_v5r24/setup.x86_64-slc6-gcc48-dbg.vars; -# fi; -# export LD_LIBRARY_PATH="/home/beat/cmtuser/OnlineDev_v5r31/InstallArea/x86_64-slc6-gcc49-do0/lib:/group/online/dataflow/cmtuser/OnlineDev_v5r31/InstallArea/x86_64-slc6-gcc49-do0/lib:/cvmfs/lhcb.cern.ch/lib/lcg/releases/Boost/1.59.0_python2.7-682d6/x86_64-slc6-gcc49-dbg/lib:$LD_LIBRARY_PATH" -# - exec -a ${UTGID} ${Checkpoint_task} ${OPTIONS} ${APP_STARTUP_OPTS}; -fi; diff --git a/Online/FarmConfig/job/PartAdder.sh b/Online/FarmConfig/job/PartAdder.sh deleted file mode 100755 index 03830f016419be2e3169878c8cc9d0376406f7fa..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/PartAdder.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -# ========================================================================= -# -# Default script to start the event reader task on the HLT farm -# -# Author M.Frank -# Version: 1.0 -# Date: 20/05/2013 -# -# ========================================================================= -# -#source /group/online/dataflow/cmtuser/OnlineDev_v5r17/setup.x86_64-slc6-gcc48-dbg.vars -#export victimnodes="hlt02(.*)" -export PYTHONPATH=${ONLINE_ENV_DIR}:${PYTHONPATH} -export AdderOptsFile=/tmp/${PARTITION_NAME}_AdderOpts.opts -export AdderStaticOpts=../options/PartAdderStatic.opts -python ./Tasklist_from_architecture.py 3 ${AdderOptsFile} -#export LD_LIBRARY_PATH="/home/beat/cmtuser/OnlineDev_v5r31/InstallArea/x86_64-slc6-gcc49-do0/lib:/group/online/dataflow/cmtuser/OnlineDev_v5r31/InstallArea/x86_64-slc6-gcc49-do0/lib:/cvmfs/lhcb.cern.ch/lib/lcg/releases/Boost/1.59.0_python2.7-682d6/x86_64-slc6-gcc49-dbg/lib:$LD_LIBRARY_PATH" -#echo "overloading online with Beat version" -#export LD_LIBRARY_PATH="/home/beat/cmtuser/OnlineDev_v6r4/InstallArea/x86_64-centos7-gcc62-do0/lib/:/cvmfs/lhcb.cern.ch/lib/lcg/releases/Boost/1.59.0_python2.7-682d6/x86_64-slc6-gcc49-dbg/lib:$LD_LIBRARY_PATH" -exec -a ${UTGID} ${Class1_task} -opts=../options/genAdder.opts diff --git a/Online/FarmConfig/job/PartPub.sh b/Online/FarmConfig/job/PartPub.sh deleted file mode 100755 index 955a29133d6b93d1b7ad85acef8a7d1531b179e0..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/PartPub.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -# ========================================================================= -# -# Default script to start the event reader task on the HLT farm -# -# Author M.Frank -# Version: 1.0 -# Date: 20/05/2013 -# -# ========================================================================= -# -if [ "$PARTITION_NAME" = "LHCbA" ]; then - cd ${FARMCONFIGROOT}/job -# export LOGFIFO=/run/fmc/logSrv.fifo; - exec -a ${UTGID} ${Class1_task} -opt=../options/DummyTask.opts -else -# export LD_LIBRARY_PATH="/home/beat/cmtuser/OnlineDev_v5r31/InstallArea/x86_64-slc6-gcc49-do0/lib:/group/online/dataflow/cmtuser/OnlineDev_v5r31/InstallArea/x86_64-slc6-gcc49-do0/lib:/cvmfs/lhcb.cern.ch/lib/lcg/releases/Boost/1.59.0_python2.7-682d6/x86_64-slc6-gcc49-dbg/lib:$LD_LIBRARY_PATH" - exec -a ${UTGID} ${Class1_task} -opts=../options/pooper.opts -fi; diff --git a/Online/FarmConfig/job/PartSaver.sh b/Online/FarmConfig/job/PartSaver.sh deleted file mode 100755 index 47b0be92af6ae2480c2692ff84e3c348868e46e5..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/PartSaver.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -# ========================================================================= -# -# Default script to start the event reader task on the HLT farm -# -# Author M.Frank -# Version: 1.0 -# Date: 20/05/2013 -# -# ========================================================================= -# -#source /group/online/dataflow/cmtuser/OnlineDev_v5r17/setup.x86_64-slc6-gcc48-dbg.vars -#export victimnodes="hlt02(.*)" -export PYTHONPATH=${ONLINE_ENV_DIR}:${PYTHONPATH} -export AdderOptsFile=/tmp/${PARTITION_NAME}_SaverOpts.opts -export AdderStaticOpts=../options/PartAdderStatic.opts -python ./Tasklist_from_architecture.py 3.1 ${AdderOptsFile} -#export LD_LIBRARY_PATH="/home/beat/cmtuser/OnlineDev_v5r31/InstallArea/x86_64-slc6-gcc49-do0/lib:/group/online/dataflow/cmtuser/OnlineDev_v5r31/InstallArea/x86_64-slc6-gcc49-do0/lib:/cvmfs/lhcb.cern.ch/lib/lcg/releases/Boost/1.59.0_python2.7-682d6/x86_64-slc6-gcc49-dbg/lib:$LD_LIBRARY_PATH" -exec -a ${UTGID} ${Class1_task} -opts=../options/HistSaver.opts diff --git a/Online/FarmConfig/job/PassThrough.sh b/Online/FarmConfig/job/PassThrough.sh deleted file mode 100755 index 8b6f42131165cb32a2a42a5c5c43e1d6c6e5848e..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/PassThrough.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash -# ========================================================================= -# -# Default script to start the passthrough process on a farm node. -# -# Author M.Frank -# Version: 1.0 -# Date: 20/05/2013 -# -# ========================================================================= -# -export ONLINETASKS=/group/online/dataflow/templates; -export PARTITIONOPTS=/group/online/dataflow/options/${PARTNAME}/${PARTNAME}_Info.opts; -export PARTITIONOPTS=${INFO_OPTIONS}; -export CHECKPOINT_SETUP_OPTIONS=${FARMCONFIGROOT}/options/Checkpoint.opts; -export CHECKPOINT_RESTART_OPTIONS=${FARMCONFIGROOT}/options/CheckpointRestart.opts; - -OPTIONS=-opts=../options/${TASK_TYPE}.opts; - -if test "${TAE_PROCESSING}" = "TAE"; -then - OPTIONS=-opts=../options/${TASK_TYPE}_TAE.opts; -fi; -# -export PYTHONPATH=${FARMCONFIGROOT}/job:${PYTHONPATH}; -echo `python ${FARMCONFIGROOT}/job/ConfigureCheckpoint.py -r ${RUNINFO} -s` | tr ";" ";\n"; -eval `python ${FARMCONFIGROOT}/job/ConfigureCheckpoint.py -r ${RUNINFO} -s`; -if test "${APP_STARTUP_OPTS}" = "-restore"; ## RunInfo flag=2 - then - echo "+++ [INFO] ${ONLINE_PROJECT_ROOT} ==> ${RESTORE_CMD}"; - mkdir -p /tmp/Commands; - python -c "import ConfigureFromCheckpoint" > /tmp/Commands/$$.cmds; - ${RESTORE_CMD} < /tmp/Commands/$$.cmds; - #eval "python -c \"import ConfigureFromCheckpoint\" | ${RESTORE_CMD}"; -else - echo "+++ [INFO] ${ONLINE_PROJECT_ROOT} ==> exec -a ${UTGID} ${Checkpoint_task} ${OPTIONS}"; -# HH=`hostname -s | tr a-z A-Z`; -# if test "${HH}" = "HLTA0328"; then -# echo "+++ [INFO] Executing modified online version from frankm."; -# . /home/frankm/cmtuser/OnlineDev_v5r24/setup.x86_64-slc6-gcc48-dbg.vars; -# fi; -# export LD_LIBRARY_PATH="/home/beat/cmtuser/OnlineDev_v5r31/InstallArea/x86_64-slc6-gcc49-do0/lib:/group/online/dataflow/cmtuser/OnlineDev_v5r31/InstallArea/x86_64-slc6-gcc49-do0/lib:/cvmfs/lhcb.cern.ch/lib/lcg/releases/Boost/1.59.0_python2.7-682d6/x86_64-slc6-gcc49-dbg/lib:$LD_LIBRARY_PATH" -# - exec -a ${UTGID} ${Checkpoint_task} ${OPTIONS} ${APP_STARTUP_OPTS}; -fi; diff --git a/Online/FarmConfig/job/PassThroughMDF.sh b/Online/FarmConfig/job/PassThroughMDF.sh deleted file mode 100755 index c989dccace800c62e2f881d986a65d206b0fef5e..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/PassThroughMDF.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# ========================================================================= -# -# Default script to start the passthrough process on a farm node. -# -# Author M.Frank -# Version: 1.0 -# Date: 20/05/2013 -# -# ========================================================================= -. ./PassThrough.sh $* diff --git a/Online/FarmConfig/job/PassThrough_Checkpointing.sh b/Online/FarmConfig/job/PassThrough_Checkpointing.sh deleted file mode 100755 index c807defec2c195d5395b7875ac0af12d5845f938..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/PassThrough_Checkpointing.sh +++ /dev/null @@ -1,100 +0,0 @@ -#!/bin/bash -# ========================================================================= -# -# Default script to start the passthrough process on a farm node. -# -# Author M.Frank -# Version: 1.0 -# Date: 20/05/2013 -# -# ========================================================================= -# -export CHECKPOINT_SETUP_OPTIONS=${FARMCONFIGROOT}/options/Checkpoint.opts; -export CHECKPOINT_RESTART_OPTIONS=${FARMCONFIGROOT}/options/CheckpointRestart.opts; -OPTIONS=-opts=../options/${TASK_TYPE}.opts; -if test "${TAE_PROCESSING}" = "TAE"; -then - OPTIONS=-opts=../options/${TASK_TYPE}_TAE.opts; -fi; -# -export LD_PRELOAD=${CHECKPOINTINGROOT}/${CMTCONFIG}/libCheckpointing.so; -export PYTHONPATH=${FARMCONFIGROOT}/job:${PYTHONPATH}; -echo exec -a ${UTGID} ${Checkpoint_task} ${OPTIONS}; -#gdb --args ${Checkpoint_task} -opts=../options/${TASK_TYPE}.opts -auto -##exit 1; -echo ${MBM_SETUP_OPTIONS} -export CHECKPOINT_BIN=${CHECKPOINTINGROOT}/${CMTCONFIG}; - -echo "============================================================================="; -echo "== MOORESTARTUP_MODE = ${MOORESTARTUP_MODE} Directory:${CHECKPOINT_DIR} "; -echo "============================================================================="; - -if test "${MOORESTARTUP_MODE}" = "NORMAL"; ## RunInfo flag=0 - then - unset MOORESTARTUP_MODE; - unset CHECKPOINT_DIR; - unset CHECKPOINT_FILE; -elif test "${MOORESTARTUP_MODE}" = "FORKING"; ## RunInfo flag=1 - then - echo "============================================================================="; - echo "== MOORESTARTUP_MODE = ${MOORESTARTUP_MODE} "; - echo "============================================================================="; - unset MOORESTARTUP_MODE; - unset CHECKPOINT_DIR; - unset CHECKPOINT_FILE; -elif test "${MOORESTARTUP_MODE}" = "CREATE_CHECKPOINT"; ## Not handled by RunInfo. Used to create checkpoints. - then - export MBM_SETUP_OPTIONS=/group/online/dataflow/cmtuser/checkpoints/cmds/MBM_setup.opts; - export CHECKPOINT_SETUP_OPTIONS=/group/online/dataflow/cmtuser/checkpoints/cmds/Checkpoint.opts; - export PYTHONPATH=${CHECKPOINT_DIR}:${PYTHONPATH}; - export MOORESTARTUP_MODE=-auto; - echo "============================================================================="; - echo "== File: ${CHECKPOINT_FILE}" - echo "== Producing CHECKPOINT file......Please be patient."; - echo "============================================================================="; - python -c "import ConfigureShell as c; c.doIt()"; - echo "============================================================================="; -elif test "${MOORESTARTUP_MODE}" = "RESTORE"; ## RunInfo flag=2 - then - unset MOORESTARTUP_MODE; - unset LD_PRELOAD; - export CHECKPOINT_FILE=`ls ${CHECKPOINT_DIR}/Checkpoint.*.gz.torrent`; - cd /localdisk/checkpoints; - CMDS=`python <<EOF -import os -base='/group/online/dataflow/cmtuser/checkpoints/' -fn = os.environ['CHECKPOINT_FILE'] -dir = os.environ['CHECKPOINT_DIR'] -c_dir = '/localdisk/checkpoints/'+dir[len(base):] -print 'mkdir -p '+c_dir+';' -print 'cd '+c_dir+';' -print '/group/online/dataflow/cmtuser/checkpoints/cmds/copy_torrent '+os.environ['CHECKPOINT_FILE']+';' -EOF` - echo ${CMDS} | tr ';' '\n'; - export CHECKPOINT_FILE=`ls ${CHECKPOINT_DIR}/Checkpoint.*.data`; - if test -f "${CHECKPOINT_FILE}"; - then - export ONLINETASKS=/group/online/dataflow/templates - export PARTITIONOPTS=/group/online/dataflow/options/${PARTNAME}/${PARTNAME}_Info.opts - if test -n "${TEST_CHECKPOINT}"; - then - echo "============================================================================="; - echo "== File: ${CHECKPOINT_FILE}"; - echo "== Testing CHECKPOINT file......Please be patient."; - echo "============================================================================="; - python -c "import ConfigureFromCheckpoint"; - echo exec -a ${UTGID} ${CHECKPOINT_BIN}/restore.exe -p 4 -e -l /dev/shm/checkpoint -i ${CHECKPOINT_FILE}; - echo "============================================================================="; - fi; - python -c "import ConfigureFromCheckpoint" | \ - exec -a ${UTGID} ${CHECKPOINT_BIN}/restore.exe -p 4 -e -l /dev/shm/checkpoint -i ${CHECKPOINT_FILE}; - else - echo " [FATAL] ============================================================================="; - echo " [FATAL] == File: ${CHECKPOINT_FILE}"; - echo " [FATAL] == CHECKPOINT FILE DOES NOT EXIST!"; - echo " [FATAL] ============================================================================="; - fi; - exit 0; -fi; - -exec -a ${UTGID} ${Checkpoint_task} ${OPTIONS} ${APP_STARTUP_OPTS}; diff --git a/Online/FarmConfig/job/PassThrough_original.sh b/Online/FarmConfig/job/PassThrough_original.sh deleted file mode 100755 index a36c0ba1ccb082e3628edf5d3e226c1d37e6ed3e..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/PassThrough_original.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# ========================================================================= -# -# Default script to start the passthrough process on a farm node. -# -# Author M.Frank -# Version: 1.0 -# Date: 20/05/2013 -# -# ========================================================================= -# -export CHECKPOINT_SETUP_OPTIONS=${FARMCONFIGROOT}/options/Checkpoint.opts; -export CHECKPOINT_RESTART_OPTIONS=${FARMCONFIGROOT}/options/CheckpointRestart.opts; -# -# -# -export LD_PRELOAD=${CHECKPOINTINGROOT}/${CMTCONFIG}/libCheckpointing.so; -if test "${TAE_PROCESSING}" = "TAE"; -then - exec -a ${UTGID} ${Checkpoint_task} -opts=../options/${TASK_TYPE}_TAE.opts; -else - exec -a ${UTGID} ${Checkpoint_task} -opts=../options/${TASK_TYPE}.opts; -fi; -#gdb --args ${Checkpoint_task} -opts=../options/${TASK_TYPE}.opts -auto diff --git a/Online/FarmConfig/job/Passthrough.py b/Online/FarmConfig/job/Passthrough.py new file mode 100644 index 0000000000000000000000000000000000000000..d56c18183f111f1860224fb8fda948c454ec396b --- /dev/null +++ b/Online/FarmConfig/job/Passthrough.py @@ -0,0 +1,67 @@ +""" + Minimal Gaudi task in the online environment + + @author M.Frank +""" +from __future__ import print_function +__version__ = "1.0" +__author__ = "Markus Frank <Markus.Frank@cern.ch>" + +import os +import sys +import Configurables +import Gaudi.Configuration as Gaudi + +import GaudiOnline +import OnlineEnvBase as OnlineEnv + +from Configurables import Online__FlowManager as FlowManager +application = GaudiOnline.Passthrough(outputLevel=OnlineEnv.OutputLevel, + partitionName=OnlineEnv.PartitionName, + partitionID=OnlineEnv.PartitionID, + classType=GaudiOnline.Class1) +application.setup_fifolog() +application.config.debug = False +buffer_name = os.getenv("MBM_INPUT_BUFFER","Events") +application.setup_mbm_access(buffer_name, True) +writer = application.setup_mbm_output('EventOutput') +writer.MBM_maxConsumerWait = 10 +writer.MBM_allocationSize = 1024*1024*10 +writer.MBM_burstPrintCount = 25000 +writer.MaxEventsPerTransaction = 10 +writer.UseRawData = False +writer.RequireODIN = False + +ev_size = Configurables.Online__EventSize('EventSize') +application.setup_hive(FlowManager("EventLoop"), 40) +application.setup_monitoring() +#application.setup_algorithms(writer, 0.05) +application.setup_algorithms([ev_size,writer], 1.0) +application.monSvc.DimUpdateInterval = 1 + +application.config.burstPrintCount = 30000 + +# Mode slection:: synch: 0 async_queued: 1 sync_queued: 2 +application.config.execMode = 1 +application.config.numEventThreads = 15 +application.config.MBM_numConnections = 8 +application.config.MBM_numEventThreads = 5 +# +application.config.execMode = 0 +application.config.numEventThreads = 15 +application.config.MBM_numConnections = 3 +application.config.MBM_numEventThreads = 4 +# +# Enable this for debugging +# +# application.config.numEventThreads = 1 +# application.config.MBM_numConnections = 1 +# application.config.MBM_numEventThreads = 1 +# +application.config.MBM_requests = [ + 'EvType=2;TriggerMask=0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF;VetoMask=0,0,0,0;MaskType=ANY;UserType=ONE;Frequency=PERC;Perc=100.0', + 'EvType=1;TriggerMask=0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF;VetoMask=0,0,0,0;MaskType=ANY;UserType=ONE;Frequency=PERC;Perc=100.0' +] +# +print('Setup complete....') + diff --git a/Online/FarmConfig/job/RU.sh b/Online/FarmConfig/job/RU.sh index cf34325d8fcdb318871ca99bdcabbff867c3eeb4..05bdbfa7dc01456ba5483522394f920b03ed5427 100755 --- a/Online/FarmConfig/job/RU.sh +++ b/Online/FarmConfig/job/RU.sh @@ -9,6 +9,9 @@ # # ========================================================================= # -. /group/online/dataflow/EventBuilder/EventBuilderRelease/setup.x86_64-centos7-gcc9-opt.vars; +. /group/online/dataflow/EventBuilder/EventBuilderRelease/setup.x86_64_v2-centos7-gcc10-opt.vars; +# . /group/online/dataflow/EventBuilder/EventBuilderRelease/setup.x86_64_v2-centos7-gcc10-do0.vars; +# . /group/online/dataflow/EventBuilder/EventBuilderRelease/setup.x86_64-centos7-gcc9-opt.vars; +#. /group/online/dataflow/EventBuilder/EventBuilderRelease/setup.${CMTCONFIG}.vars; cd ${EVENTBUILDINGROOT}/options; `dataflow_task Class1` -opts=EB_RU.opts ${AUTO_STARTUP} ${DEBUG_STARTUP} diff --git a/Online/FarmConfig/job/ReaderMDF.sh b/Online/FarmConfig/job/ReaderMDF.sh deleted file mode 100755 index 919672320912277c48000cde81a4fccf4cb9f33b..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/ReaderMDF.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -# -NODE=`hostname -s | tr a-z A-Z`; -export NODE_OPTIONS=${NON_DYNAMIC_OPTS}/Nodes/${NODE}_TriggerInfo.opts; -export GO_SERVICE_NAME=${PARTITION_NAME}_${NODE}/Trigger; -# -exec -a ${UTGID} ${DATAFLOW_task} -class=Class2 -opts=../options/${TASK_TYPE}.opts diff --git a/Online/FarmConfig/job/Receiver.sh b/Online/FarmConfig/job/Receiver.sh deleted file mode 100755 index f5de6a3564ef6fed977a8037d3909ca75429c837..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/Receiver.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -# -export TAN_PORT=YES; -export TAN_NODE=${DATAINTERFACE}; -exec -a ${UTGID} ${Class1_task} -opts=../options/RCV.opts diff --git a/Online/FarmConfig/job/Rich.py b/Online/FarmConfig/job/Rich.py deleted file mode 100755 index 51d5cfd1aa39fa183e6c79eeb0743242eeab0d09..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/Rich.py +++ /dev/null @@ -1,82 +0,0 @@ -from builtins import range -import sys -import os -import Criteria -import time - -Crits=Criteria.Criteria() -Crits.__init__() -Crits.keepRuns =[192228,192229,192231,192232,192233,192234,192235,192236,192237,192297,192299,192300, - 192320,192321,192322,192324,192325,192327,192332,192334,192336,192339,192341,192342, - 192343,192344,192713,192714,192715,192739,192740,192784,192785,192786,192790,192792, - 192793,192795,192796,193218,193220,193222,193223,193252,193255,193436,193440,193533, - 193534,193537,193590,193593,193675,193678,193786,193788,193790,193791,193793,193819, - 193822,193864,193871,193910,193957,194015,194019,194050,194981,194986,195017,195091, - 195093,195094,195096,195204,195206,195238,195239,195242,195244,195245,195246,195247, - 195277,195278,195279,195281,195282,195284,195285,195286,195303,195304,195305,195306, - 195307,195309,195313,195416,195418,195483,195487,195530,195531,195532,195533,195534, - 195535,195536,195537,195538,195539,195542,195543,195600,195602,195603,195605,195948, - 195950,196905,196907,197199,197204,197205,197223,197226,197227,197279,197281,197283, - 197303,197304,197306,197307,197309,197336,197338,197360,197362,197364,197381,197384, - 197404,197407,197420,197423,197424,197536,197538,197539,197543,197567,197570,197611, - 197614,197650,197653,197686,197688,197691,199066,199069,199446,199448,199450,199464, - 199466,199492,199494,199496,199526,199527,199529,199531,199565,199567,199594,199596, - 199598,199620,199623,199628,199661,199665,199691,199693,199740,199743,199771,199774, - 199814,199816,199818,199837,199840,199841,199859,199862,201085,201087,201285,201287, - 201336,201337,201339,201368,201370,201399,201404,201441,201443,201464,201467,201482, - 201485,201595,201597,201632,201634,201664,201667,201716,201719,201794,201799,201965, - 201968,201993,201996,201997,202165,202168,202171,202173,202187,202187,202189,202190, - 202193,202214,202216,202217,202218,202219,202220,202221,202222,202223,202261,202262, - 202263,202264,202265,202266,202267,202268,202276,202278,202280,202282,202283,202284, - 202285,202286,202287,202288,202289,202290,202291,202292,202305,202313,202316,202317, - 202318,202319,202320,202321,202322,202323,202335,202337,202338,202339,202341,202342, - 202343,202344,202345,202346,202347,202360,202363,202364,202365,202366,202367,202368, - 202369,202370,202371,202372,202373,202374,202432,202433,202434,202435,202437,202438, - 202439,202441,202442,202450,202452,202454,202455,202456,202457,202458,202459,202460, - 202461,202464,202465,202466,202467,202468,202469,202470,202471,202472,202473,202474, - 202703,202705,202706,202707,202709,202710,202711,202750,202752,202800,202802,202806, - 202847,202849,202854,202884,205966,205992,205994,205995,205997,205999,206000,206061, - 206110,206112,206113,206115,206117,206118,206121,206122,206123,206124,206126,206162, - 206165,206167,206170,206171,206172,206173,206174,206175,206176,206177,206180,206182, - 206188,206189,206191,206193,206194,206195,206198,206202,206203,206264,206265,206293, - 206294,206297,206298,206302,206303,206304,206305,206322,206323,206325,206326,206337, - 206339,206340,206341,206342,206344,206345,206346,206370,206400,206402,206404,206407, - 206409,206410,206412,206415,206416,206417,206418,206419,206420,206421,206422,206423, - 206425,206427,206428,206429,206535,206537,206538,206539,206541,206543,206544,206545, - 206546,206547,206548,206549,206572,206574,206575,206576,206581,206583,206584,206585, - 206586,206587,206589,206590,206617,206638,206641,206642,206643,206644,206675,206677, - 206678,206680,206681,206682,206684,206685,206687,206688,206689,206690,206692,206704, - 206708,206709,206711,206712,206754,206757,206758,206759,206788,206791,206792,206852, - 206854,206857,206875,206877,206878,206879,206882,206883,206884,206885,206886,206887, - 206888,206889,206942,206945,206946,207001,207008,207010,207012,207013,207013,207015, - 207045,207047,207048,207101,207102,207103,207104,207105,207106,207123,207125,207177, - 207180,207262,207266,207297,207298,207300,207302,207303,207305,207306,207307,207308, - 207309,207376,207409,207413,207429,207442,207444,207465,207466,207471,207472,207497, - 207498,207542,207577,207579,207581,207582,207735,207814,207874,207878,207919,207922, - 207924,207981,207983,207987,207988,207989,208014,208016,208021,208063,208111,208113, - 208168,208172,208173,208217,208218,208319,208320,208322,208325,208327,208347,208348, - 208351,208384,208394,208396,208398,208422,208425,208458,208459,208460,208461,208463, - 208464,208465,208466,208468,208469,208610,208611,208613,208623,208630,208631,208632, - 208637,208640,208641,208644,208645,208743,208745,208748,208750,208752,208753,208754, - 208755,208787,208790,208791,208814,208816,208850,208853,208890,208977,208979,209028, - 209032,209139,209140,209193,209194,209196,209260,209262,209263,209267,209353,209355, - 209359,209360,209361,209379,209382,209383,209422,209423,209433,209434,209436,209438, - 209554,209589,209628,209630,209632,209633,209662,209693,209724,209726,209770,209772, - 209773,209774,209775,209798,209836,209838,209888,209890,209891,209895,209922,209925, - 209946,209948,210015,210017,210047,210051,210052,210053,210055,210056,210057,210058, - 210085,210117,210118,210120,210122,210123,210124,210158,210161,210194,210197,210198, - 210216,210694,210695,210715,210744,210746,210778,210781,210786,210787,210788,210843, - 210845,210847,210867,210869,210895,210897,211050,211414,211416,211418,211419,211448, - 211450,211454,211502,211505,211507,211655,211657,211682,211746,211747,211796,211798, - 211800,211813,211840,211843,211863,211882,211900,211902,211904,211905,211928,211930, - 211932,211936,211937,212001,212004,212005,212018,212021,212065,212066,212068,212120, - 212123,212142,212144,212185,212188,212219,212249,212251,212253,212254,212284,212286, - 212287,212305,212624,212664,212666,212667,212668,212670,212707,212709,212711,212712, - 212713,212714,212729,212755,212758,212779,212856,212860 - ] -Crits.keepRuns.extend(list(range(212860,250000))) - -#Crits.addTimeInterval([time.mktime(time.strptime("1 Jan 2017","%d %b %Y")),time.time()+3*86400]) -# Crits.incRuns=range(177358,183699+1) -#Crits.exclRuns=range(183700,200000) -#Crits.exclRuns.extend(range(100000 , 177358 )) diff --git a/Online/FarmConfig/job/RichDAQCalib.sh b/Online/FarmConfig/job/RichDAQCalib.sh deleted file mode 100755 index 50d12ec48bdba96283ffe6d7e4388408948fa950..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/RichDAQCalib.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -# -. /group/rich/scripts/RichCalibMon.sh ${DIM_DNS_NODE} ${PARTITION_NAME} ${RUN_TYPE} diff --git a/Online/FarmConfig/job/RouteTester.sh b/Online/FarmConfig/job/RouteTester.sh deleted file mode 100755 index eb5d961148b65ab95de9c1cbf9c642ddfac28f96..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/RouteTester.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -# -export PYTHONPATH=${ONLINE_ENV_DIR}:${PYTHONPATH}; -# -cmd=`python <<EOF -import OnlineEnvBase as Online -print 'export EVENTSELECTOR_REQ1="EvType=2;TriggerMask=0xffffffff,0xffffffff,0xffffffff,0xffffffff;VetoMask=0,0,0,0;MaskType=ANY;UserType=VIP;Frequency=PERC;Perc=%f"'%(Online.AcceptRate*100.,); -EOF` -echo [DEBUG] $cmd; -eval $cmd; -export TAN_PORT=YES; -export TAN_NODE=${DATAINTERFACE}; -echo [DEBUG] SUBFARM_OPTIONS: ${SUBFARM_OPTIONS}; -echo [DEBUG] Eventselector request: ${EVENTSELECTOR_REQ1}; -exec -a ${UTGID} ${Class2_task} -opts=../options/RouteTester.opts diff --git a/Online/FarmConfig/job/RunDBServ.sh b/Online/FarmConfig/job/RunDBServ.sh deleted file mode 100755 index f47c267d7f9f746cba455c2d020544a2979deb55..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/RunDBServ.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# ========================================================================= -# -# Script to start the HLT2 histogram adder on the farm -# -# Author R. Aaij -# Version: 1.0 -# Date: 16/07/2015 -# -# ========================================================================= -# -if test "`uname -a | grep \".el6\"`" != ""; # SLC6 -then - export CMTCONFIG=x86_64-slc6-gcc62-dbg -elif test "`uname -a | grep el7`" != ""; # SLC7 (Centos 7) -then - export CMTCONFIG=x86_64-centos7-gcc62-dbg -fi; - -read COMMAND <<EOF -import GaudiKernel.ProcessJobOptions;\ -from Gaudi.Configuration import importOptions;\ -GaudiKernel.ProcessJobOptions.printing_level=3;\ -from Monitoring import RunDBInfoServer;\ -RunDBInfoServer.run('ipc:///run/HLT2/hlt2RunDB') -EOF - -. /group/hlt/monitoring/ONLINE/ONLINE_RELEASE/setup.$CMTCONFIG.vars -export UTGID -export PYTHONHOME=`python -c "import sys; print '/'.join(sys.path[-1].split('/')[:-3])"` -exec -a ${UTGID} python -c "${COMMAND}" -# exec -a ${UTGID} ${Class1_task} -opt=command="${COMMAND}" diff --git a/Online/FarmConfig/job/SFBusyMon.sh b/Online/FarmConfig/job/SFBusyMon.sh deleted file mode 100755 index 0291069f74677fdd04a9fcc99dd214ae71e01807..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/SFBusyMon.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -cd /group/online/dataflow/cmtuser -export User_release_area=`pwd`; -export CMTPROJECTPATH=`pwd`:${CMTPROJECTPATH}; -source OnlineRelease/setup.x86_64-centos7-gcc62-do0.vars -cd OnlineRelease/Online/FarmConfig/job -export msg_svc=LHCb::FmcMessageSvc -export HOST=`hostname` -export UTGID=GEN_${HOST}_BusyMon -export AddTest=AddTest_Victim.opts -export vnodes="hlt[a-f][0-1][0-9]" -if [ -z `echo $HOST |egrep -e $vnodes` ] ; then export AddTest=AddTest_EMPTY.opts ; fi -export LOGFIFO=/run/fmc/logGaudi.fifo -#export LD_LIBRARY_PATH="/home/beat/cmtuser/OnlineDev_v5r31/InstallArea/x86_64-slc6-gcc49-do0/lib:/group/online/dataflow/cmtuser/OnlineDev_v5r31/InstallArea/x86_64-slc6-gcc49-do0/lib:/cvmfs/lhcb.cern.ch/lib/lcg/releases/Boost/1.59.0_python2.7-682d6/x86_64-slc6-gcc49-dbg/lib:$LD_LIBRARY_PATH" -GaudiOnlineExe.exe libGaudiOnline.so OnlineTask -msgsvc=$msg_svc -tasktype=LHCb::Class1Task -main=/group/online/dataflow/templates/options/Main.opts -opts=../options/SFBsyAdder.opts -auto diff --git a/Online/FarmConfig/job/SFThrottleCollect.sh b/Online/FarmConfig/job/SFThrottleCollect.sh deleted file mode 100755 index 1906bf6be6157bef0b69c7b8cedc34cd68c80756..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/SFThrottleCollect.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -. /group/online/dataflow/cmtuser/OnlineRelease/setup.x86_64-centos7-gcc62-do0.vars -HLTThrottleCollect.exe diff --git a/Online/FarmConfig/job/STDAQCalib.sh b/Online/FarmConfig/job/STDAQCalib.sh deleted file mode 100755 index f8400243af93428ed9d8d8789571f39ed9143a1e..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/STDAQCalib.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -# -. /group/st/sw/scripts/STCalibFilter.sh $${DIM_DNS_NODE} ${PARTITION_NAME} ${RUN_TYPE} diff --git a/Online/FarmConfig/job/Sender.sh b/Online/FarmConfig/job/Sender.sh deleted file mode 100755 index 73c20ce6e57d625a7932165646085229d9ec1211..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/Sender.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -# -export TAN_PORT=YES; -export TAN_NODE=${DATAINTERFACE}; -#echo [DEBUG] SUBFARM_OPTIONS: ${SUBFARM_OPTIONS}; -exec -a ${UTGID} ${DATAFLOW_task} -class=Class2 -opts=../options/${TASK_TYPE}.opts; diff --git a/Online/FarmConfig/job/SubFarmAdder.sh b/Online/FarmConfig/job/SubFarmAdder.sh deleted file mode 100755 index 76905d5ea24f818e03bda513ca524bdbdb21e3c1..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/SubFarmAdder.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# ========================================================================= -# -# Default script to start the event reader task on the HLT farm -# -# Author M.Frank -# Version: 1.0 -# Date: 20/05/2013 -# -# ========================================================================= -# -if [ "${PARTITION_NAME}" = "LHCb2" ]; then - ./Hlt2Adder.sh -# ./DummyTask.sh -else -# if [ "${PARTITION_NAME}" = "LHCb" ]; then -# export victimnodes="hltb01(.*)" - export PYTHONPATH=${ONLINE_ENV_DIR}:${PYTHONPATH} - export AdderOptsFile=/tmp/${PARTITION_NAME}_AdderOpts.opts - export AdderStaticOpts=../options/SubFarmAdderStatic.opts - python ./Tasklist_from_architecture.py 2 ${AdderOptsFile} - h=`hostname` -# if [ "$h" == "$h" ]; then -# echo "overloading online with Beat version" -# export LD_LIBRARY_PATH="/home/beat/cmtuser/OnlineDev_v6r4/InstallArea/x86_64-centos7-gcc62-do0/lib/:/cvmfs/lhcb.cern.ch/lib/lcg/releases/Boost/1.59.0_python2.7-682d6/x86_64-slc6-gcc49-dbg/lib:$LD_LIBRARY_PATH" -# export LD_LIBRARY_PATH="/group/online/dataflow/cmtuser/OnlineDev_v6r4/build.x86_64-centos7-gcc62-do0/lib/:/group/online/dataflow/cmtuser/OnlineDev_v5r31/InstallArea/x86_64-slc6-gcc49-do0/lib:/cvmfs/lhcb.cern.ch/lib/lcg/releases/Boost/1.59.0_python2.7-682d6/x86_64-slc6-gcc49-dbg/lib:$LD_LIBRARY_PATH" -# else -# echo "HOSTNAME == " $h -# fi; -# fi - exec -a ${UTGID} ${Class1_task} -opts=../options/genAdder.opts -fi diff --git a/Online/FarmConfig/job/Tasklist_from_architecture.py b/Online/FarmConfig/job/Tasklist_from_architecture.py deleted file mode 100755 index 9db800de4a630ddc143c478789959610b6d003db..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/Tasklist_from_architecture.py +++ /dev/null @@ -1,451 +0,0 @@ -from xml.dom import minidom -import sys -import os -import OnlineEnvBase -import re -import socket -CounterDebugSvcs = ["DskWriter"] -HistDebugSvcs =["AligWrk"] -vnode=False - -def VictimNode(): - victimnodes_re = [] - vnodes="" - vnodes=os.getenv("victimnodes","") - if vnodes!="": - victimnodes = vnodes.split(",") - for i in victimnodes: - victimnodes_re.append(re.compile(i,re.IGNORECASE)) - hname=socket.gethostname().split('.')[0] - for i in victimnodes_re: - if i.match(hname) != None: - return True - -def TaskListfromArch(arch, tasklist): - xmldoc = minidom.parse(arch) - itemlist = xmldoc.getElementsByTagName('task') -# tasklist = [] - for s in itemlist: - nam = s.attributes['name'] -# if not nam.find('MEPR')>=0: - tasklist.append(s.attributes['name'].value) -def OptionsfromTasks(tasklist,level,ofile,pname,dohostdns): - f = open(ofile,'w') - f.write("// Adder Level "+level+"=====================\n") - if vnode: - f.write("// This is a victim node\n") - if level=="1": - if pname=="LHCb": - f.write("""#include "$INFO_OPTIONS" -ApplicationMgr.ExtSvc += {"MonitorSvc"}; - -ApplicationMgr.EventLoop = "LHCb::OnlineRunable/EmptyEventLoop"; -ApplicationMgr.Runable = "LHCb::OnlineRunable/Runable"; -ApplicationMgr.HistogramPersistency = "NONE"; -ApplicationMgr.EvtSel = "NONE"; - -Runable.Wait = 3; // 1 of running as daemon (Class1 task) - -MessageSvc.fifoPath = "$LOGFIFO"; -MessageSvc.OutputLevel = @OnlineEnv.OutputLevel; -MonitorSvc.OutputLevel = @OnlineEnv.OutputLevel; -HistogramPersistencySvc.Warnings = false; -MonitorSvc.CounterUpdateInterval = 5; -""") - else: - f.write("""#include "$INFO_OPTIONS" -ApplicationMgr.ExtSvc += {"MonitorSvc"}; - -ApplicationMgr.EventLoop = "LHCb::OnlineRunable/EmptyEventLoop"; -ApplicationMgr.Runable = "LHCb::OnlineRunable/Runable"; -ApplicationMgr.HistogramPersistency = "NONE"; -ApplicationMgr.EvtSel = "NONE"; - -Runable.Wait = 3; // 1 of running as daemon (Class1 task) - -MessageSvc.fifoPath = "$LOGFIFO"; -MessageSvc.OutputLevel = @OnlineEnv.OutputLevel; -MonitorSvc.OutputLevel = @OnlineEnv.OutputLevel; -HistogramPersistencySvc.Warnings = false; -MonitorSvc.CounterUpdateInterval = 5; -""") - else: - f.write("""#include "$INFO_OPTIONS" -ApplicationMgr.ExtSvc += {"MonitorSvc"}; -ApplicationMgr.EventLoop = "LHCb::OnlineRunable/EmptyEventLoop"; -ApplicationMgr.Runable = "LHCb::OnlineRunable/Runable"; -ApplicationMgr.HistogramPersistency = "NONE"; -ApplicationMgr.EvtSel = "NONE"; - -Runable.Wait = 3; // 1 of running as daemon (Class1 task) - -MessageSvc.fifoPath = "$LOGFIFO"; -MessageSvc.OutputLevel = @OnlineEnv.OutputLevel; -MonitorSvc.OutputLevel = @OnlineEnv.OutputLevel; -HistogramPersistencySvc.Warnings = false; -MonitorSvc.CounterUpdateInterval = 5; -""") - - if level=="1": - InDns = os.getenv("InDns","<dns>") - OutDns = os.getenv("OutDns","<dns>") - InDns = "\""+InDns+"\"" - OutDns = "\""+OutDns+"\"" - if level =="2": - InDns = os.getenv("InDns","<node>") - OutDns = os.getenv("OutDns","hlt01") - InDns = "\""+InDns+"\"" - OutDns = "\""+OutDns+"\"" - elif level == "3": - InDns = os.getenv("InDns","hlt01") - OutDns = os.getenv("OutDns","mona08") - InDns = "\""+InDns+"\"" - OutDns = "\""+OutDns+"\"" - elif level == "3.1": - InDns = os.getenv("InDns","mona08") - OutDns = os.getenv("OutDns","mona08") - InDns = "\""+InDns+"\"" - OutDns = "\""+OutDns+"\"" - elif level == "4": - InDns = os.getenv("InDns","mona08") - OutDns = os.getenv("OutDns","mona08") - InDns = "\""+InDns+"\"" - OutDns = "\""+OutDns+"\"" - if level == "1": - histsvc = [] - cntsvc = [] - for s in tasklist: - if 'NodeAdder' in s: - continue - if 'AligAdder' in s: - continue - hsvc = s#+"HistAdder" - f.write("ApplicationMgr.ExtSvc += {\"AdderSvc/"+hsvc+"HistAdder\"};\n") - csvc = s#+"CountAdder" - f.write("ApplicationMgr.ExtSvc += {\"AdderSvc/"+csvc+"CountAdder\"};\n") - histsvc.append(hsvc) - cntsvc.append(csvc) - f.write("\n") - - for s in histsvc: - svc = s+"HistAdder" - f.write(svc+".PartitionName = @OnlineEnv.PartitionName;\n") - f.write(svc+".MyName = \"<part>_<node>_"+s+"\";\n") - f.write(svc+".TaskPattern = \"<part>_<node>_"+s+"_(.*)\";\n") - f.write(svc+".ServicePattern = \"MON_<part>_<node>_"+s+"_(.*)/Histos/\";\n") - f.write(svc+".AdderClass = \"hists\";\n") - f.write(svc+".ReceiveTimeout = 5;\n") - f.write("\n") - if dohostdns: - f.write(svc+".InDNS = "+InDns+";\n") - f.write(svc+".OutDNS = "+OutDns+";\n") - if pname == "LHCbA": # overwrite certain options for the Alignment... - f.write(svc+".SaveInterval = -1;\n"); - f.write(svc+".SaveonUpdate = false;\n"); - f.write(svc+".SaveSetTaskName= \""+svc+"\";\n"); - f.write(svc+".ReceiveTimeout = 1;\n") - if pname =="LHCbA": - f.write(svc+".EoRTmoFactor = 2;\n") -# f.write(svc+".DebugOn = true;\n") - f.write(svc+".GotoPause = false;\n") -# f.write(svc+".DebugOn = true;\n") - if vnode: - if s in HistDebugSvcs: - f.write(svc+".DebugOn = true;\n") - for s in cntsvc: - svc = s+"CountAdder" - f.write(svc+".PartitionName = @OnlineEnv.PartitionName;\n") - f.write(svc+".MyName = \"<part>_<node>_"+s+"\";\n") - f.write(svc+".TaskPattern = \"<part>_<node>_"+s+"_(.*)\";\n") - f.write(svc+".ServicePattern = \"MON_<part>_<node>_"+s+"_(.*)/Counter/\";\n") - f.write(svc+".AdderClass = \"Counter\";\n") - f.write(svc+".ReceiveTimeout = 4;\n") - if vnode: - if s in CounterDebugSvcs: - f.write(svc+".DebugOn = true;\n") - if pname == "LHCbA": - f.write(svc+".GotoPause = false;\n") - f.write(svc+".ReceiveTimeout = 0;\n") - if dohostdns: - f.write(svc+".InDNS = "+InDns+";\n") - f.write(svc+".OutDNS = "+OutDns+";\n") - f.write("\n") -# s = "BusyMon" -# svc = s+"CountAdder" -# f.write(svc+".PartitionName = @OnlineEnv.PartitionName;\n") -# f.write(svc+".MyName = \"<part>_<node>_"+s+"\";\n") -# f.write(svc+".TaskPattern = \"GEN_<node>_"+s+"\";\n") -# f.write(svc+".ServicePattern = \"MON_GEN_<node>_"+s+"/Counter/\";\n") -# f.write(svc+".AdderClass = \"Counter\";\n") -# f.write(svc+".ReceiveTimeout = 2;\n") - if vnode: - if s in CounterDebugSvcs: - f.write(svc+".DebugOn = true;\n") - if pname == "LHCbA": - f.write(svc+".GotoPause = false;\n") - f.write(svc+".ReceiveTimeout = 0;\n") - if dohostdns: - f.write(svc+".InDNS = "+InDns+";\n") - f.write(svc+".OutDNS = "+OutDns+";\n") - f.write("\n") - f.write("ApplicationMgr.ExtSvc += {\"AdderSvc/"+svc+"\"};\n") - elif level == "2": -# f.write("ApplicationMgr.ExtSvc += {\"AdderSvc/"+"BusyAdder"+"CountAdder\"};\n") -# f.write(""" -# BusyAdderCountAdder.MyName = "<part>_<node>_BusySvc"; -# BusyAdderCountAdder.PartitionName = @OnlineEnv.PartitionName; -# BusyAdderCountAdder.TaskPattern = "<part>_<node>[0-9][0-9]_NodeAdder_0"; -# BusyAdderCountAdder.ServicePattern = "MON_<part>_<node>[0-9][0-9]_BusyMon/Counter/"; -# BusyAdderCountAdder.AdderClass = "Counter"; -# BusyAdderCountAdder.ReceiveTimeout = 6; -# """) -# f.write("BusyAdderCountAdder.InDns = "+InDns+";\n") -# f.write("BusyAdderCountAdder.OutDns = "+OutDns+";\n") - histsvc = [] - cntsvc = [] - for s in tasklist: - if 'SubFarmAdder' in s: - continue - hsvc = s#+"HistAdder" - f.write("ApplicationMgr.ExtSvc += {\"AdderSvc/"+hsvc+"HistAdder\"};\n") - csvc = s#+"CountAdder" - f.write("ApplicationMgr.ExtSvc += {\"AdderSvc/"+csvc+"CountAdder\"};\n") - histsvc.append(hsvc) - cntsvc.append(csvc) - f.write("\n") - - for s in histsvc: - svc = s+"HistAdder" - f.write(svc+".PartitionName = @OnlineEnv.PartitionName;\n") - f.write(svc+".MyName = \"<part>_<node>_"+s+"\";\n") - f.write(svc+".TaskPattern = \"<part>_<node>[0-9][0-9]_NodeAdder_0\";\n") - f.write(svc+".ServicePattern = \"MON_<part>_<node>[0-9][0-9]_"+s+"/Histos/\";\n") - f.write(svc+".AdderClass = \"hists\";\n") - f.write(svc+".ReceiveTimeout = 8;\n") - f.write(svc+".InDNS = "+InDns+";\n") - f.write(svc+".OutDNS = "+OutDns+";\n") - if vnode: - if s in HistDebugSvcs: - f.write(svc+".DebugOn = true;\n") - if pname == "LHCbA": # overwrite certain options for the Alignment... - f.write(svc+".SaveInterval = -1;\n"); - f.write(svc+".SaveonUpdate = false;\n"); - f.write(svc+".SaveSetTaskName= \""+svc+"\";\n"); - f.write(svc+".ReceiveTimeout = 2;\n") - f.write(svc+".EoRTmoFactor = 8;\n") -# f.write(svc+".DebugOn = true;\n") - f.write("\n") - - - for s in cntsvc: - svc = s+"CountAdder" - f.write(svc+".PartitionName = @OnlineEnv.PartitionName;\n") - f.write(svc+".MyName = \"<part>_<node>_"+s+"\";\n") - f.write(svc+".TaskPattern = \"<part>_<node>[0-9][0-9]_NodeAdder_0\";\n") - f.write(svc+".ServicePattern = \"MON_<part>_<node>[0-9][0-9]_"+s+"/Counter/\";\n") - f.write(svc+".ReceiveTimeout = 8;\n") - f.write(svc+".AdderClass = \"Counter\";\n") - f.write(svc+".InDNS = "+InDns+";\n") - f.write(svc+".OutDNS = "+OutDns+";\n") - if vnode: - if s in CounterDebugSvcs: - f.write(svc+".DebugOn = true;\n") - if pname == "LHCbA": - f.write(svc+".GotoPause = true;\n") - f.write(svc+".ReceiveTimeout = 0;\n") - f.write("\n") - elif level == "3": -# f.write("ApplicationMgr.ExtSvc += {\"AdderSvc/"+"BusyAdder"+"CountAdder\"};\n") -# f.write(""" -# BusyAdderCountAdder.MyName = "<part>_Busy_00"; -# BusyAdderCountAdder.PartitionName = @OnlineEnv.PartitionName; -# BusyAdderCountAdder.TaskPattern = "<part>_hlt[a-z][0-9][0-9]_SubFarmAdder_0"; -# BusyAdderCountAdder.ServicePattern = "MON_<part>_hlt[a-z][0-9][0-9]_BusySvc/Counter/"; -# BusyAdderCountAdder.AdderClass = "Counter"; -# BusyAdderCountAdder.ReceiveTimeout = 8; -# """) -# f.write("BusyAdderCountAdder.InDns = "+InDns+";\n") -# f.write("BusyAdderCountAdder.OutDns = "+OutDns+";\n") - histsvc = [] - cntsvc = [] -# histsvc.append("Adder") -# cntsvc.append("BusySvc") -# tasklist.remove("MEPrx") - for s in tasklist: - hsvc = s#+"HistAdder" - f.write("ApplicationMgr.ExtSvc += {\"AdderSvc/"+hsvc+"HistAdder\"};\n") - csvc = s#+"CountAdder" - f.write("ApplicationMgr.ExtSvc += {\"AdderSvc/"+csvc+"CountAdder\"};\n") - histsvc.append(hsvc) - cntsvc.append(csvc) - f.write("\n") - - for s in histsvc: - svc = s+"HistAdder" - f.write(svc+".PartitionName = @OnlineEnv.PartitionName;\n") - f.write(svc+".MyName = \"<part>_hlt01_"+s+"_00\";\n") - f.write(svc+".TaskPattern = \"<part>_HLT[a-z][0-9][0-9]_SubFarmAdder_(.*)\";\n") - f.write(svc+".ServicePattern = \"MON_<part>_hlt[a-z][0-9][0-9]_"+s+"/Histos/\";\n") - f.write(svc+".AdderClass = \"hists\";\n") - f.write(svc+".ReceiveTimeout = 12;\n") - f.write(svc+".InDNS = "+InDns+";\n") - f.write(svc+".OutDNS = "+OutDns+";\n") -# f.write(svc+".SaveRootDir = \"/hist/Savesets\";\n"); -# f.write(svc+".IsSaver = true;\n"); -# f.write(svc+".SaveInterval = -1;\n"); -# f.write(svc+".SaveonUpdate = false;\n"); -# f.write(svc+".SaveSetTaskName= \""+svc+"\";\n"); - if vnode: - if s in HistDebugSvcs: - f.write(svc+".DebugOn = true;\n") - if pname == "LHCbA" and s=="AligWrk": # overwrite certain options for the Alignment... -# f.write(svc+".DebugOn = true;\n") - act = "" - act=OnlineEnvBase.Activity - acts = act.split('|') - if len(acts) > 1: - altype = acts[1] - else: - altype = acts[0] -# f.write(svc+".SaveRootDir = \"/hist/Savesets\";\n"); -# f.write(svc+".IsSaver = true;\n"); -# f.write(svc+".SaveInterval = -1;\n"); -# f.write(svc+".SaveonUpdate = false;\n"); -# f.write(svc+".SaveSetTaskName= \""+svc+"\";\n"); -# f.write(svc+".SaveInterval = -1;\n"); -# f.write(svc+".SaveonUpdate = false;\n"); -# f.write(svc+".SaveSetTaskName= \"AligWrk_"+altype+"\";\n"); -# f.write(svc+".ReceiveTimeout = 3;\n") -# # f.write(svc+".PauseOnEOR = true;\n") -# f.write(svc+".EoRTmoFactor = 15;\n") - f.write("\n") - - for s in cntsvc: - svc = s+"CountAdder" - f.write(svc+".PartitionName = @OnlineEnv.PartitionName;\n") - f.write(svc+".MyName = \"<part>_"+s+"_00\";\n") - f.write(svc+".TaskPattern = \"<part>_HLT[a-z][0-9][0-9]_SubFarmAdder_(.*)\";\n") - f.write(svc+".ServicePattern = \"MON_<part>_hlt[a-z][0-9][0-9]_"+s+"/Counter/\";\n") - f.write(svc+".AdderClass = \"Counter\";\n") - f.write(svc+".ReceiveTimeout = 12;\n") - f.write(svc+".InDNS = "+InDns+";\n") - f.write(svc+".OutDNS = "+OutDns+";\n") - if vnode: - if s in CounterDebugSvcs: - f.write(svc+".DebugOn = true;\n") - if pname == "LHCbA": - f.write(svc+".ReceiveTimeout = 0;\n") -# f.write(svc+".GotoPause = true;\n") - f.write("\n") - elif level == "3.1": #Top level saver - histsvc = [] - histsvc.append("Adder") -# tasklist.remove("MEPrx") - for s in tasklist: - hsvc = s#+"HistAdder" - f.write("ApplicationMgr.ExtSvc += {\"AdderSvc/"+hsvc+"HistAdder\"};\n") - histsvc.append(hsvc) - f.write("\n") - - for s in histsvc: - svc = s+"HistAdder" - f.write(svc+".PartitionName = @OnlineEnv.PartitionName;\n") - f.write(svc+".MyName = \"<part>_Saverhlt01_"+s+"_00\";\n") - f.write(svc+".TaskPattern = \"MON_<part>_HLT02_PartAdder_0\";\n") - f.write(svc+".ServicePattern = \"MON_<part>_hlt01_"+s+"_00/Histos/\";\n") - f.write(svc+".AdderClass = \"hists\";\n") - f.write(svc+".ReceiveTimeout = 12;\n") - f.write(svc+".InDNS = "+InDns+";\n") - f.write(svc+".OutDNS = "+OutDns+";\n") - f.write(svc+".SaveRootDir = \"/hist/Savesets\";\n"); - f.write(svc+".IsSaver = true;\n"); - f.write(svc+".SaveInterval = 900;\n"); - f.write(svc+".SaveonUpdate = false;\n"); - f.write(svc+".SaveSetTaskName= \""+s+"\";\n"); - if vnode: - if s in HistDebugSvcs: - f.write(svc+".DebugOn = true;\n") - if pname == "LHCbA" and s=="AligWrk": # overwrite certain options for the Alignment... -# f.write(svc+".DebugOn = true;\n") - act = "" - act=OnlineEnvBase.Activity - acts = act.split('|') - if len(acts) > 1: - altype = acts[1] - else: - altype = acts[0] - f.write(svc+".SaveInterval = -1;\n"); - f.write(svc+".SaveonUpdate = true;\n"); - f.write(svc+".SaveSetTaskName= \"AligWrk_"+altype+"\";\n"); - f.write(svc+".ReceiveTimeout = 3;\n") -# f.write(svc+".PauseOnEOR = true;\n") - f.write(svc+".EoRTmoFactor = 15;\n") -# f.write(svc+".DebugOn = true;\n") - f.write("\n") - elif level == "4": - histsvc = [] - cntsvc = [] -# histsvc.append("Adder") -# cntsvc.append("Busy") - for s in tasklist: - hsvc = s#+"HistAdder" - f.write("ApplicationMgr.ExtSvc += {\"AdderSvc/"+hsvc+"HistAdder\"};\n") - csvc = s#+"CountAdder" - f.write("ApplicationMgr.ExtSvc += {\"AdderSvc/"+csvc+"CountAdder\"};\n") - histsvc.append(hsvc) - cntsvc.append(csvc) - f.write("\n") - - for s in histsvc: - svc = s+"HistAdder" - f.write(svc+".PartitionName = @OnlineEnv.PartitionName;\n") - f.write(svc+".MyName = \"<part>_X_"+s+"\";\n") - f.write(svc+".TaskPattern = \"<part>_HLT01_PartAdder_(.*)\";\n") - f.write(svc+".ServicePattern = \"MON_<part>_hlt01_"+s+"/Histos/\";\n") - f.write(svc+".AdderClass = \"hists\";\n") - f.write(svc+".ReceiveTimeout = 12;\n") - f.write(svc+".InDNS = "+InDns+";\n") - f.write(svc+".OutDNS = "+OutDns+";\n") - if vnode: - if s in HistDebugSvcs: - f.write(svc+".DebugOn = true;\n") - f.write("\n") - - for s in cntsvc: - svc = s+"CountAdder" - f.write(svc+".PartitionName = @OnlineEnv.PartitionName;\n") - f.write(svc+".MyName = \"<part>_X_"+s+"\";\n") - f.write(svc+".TaskPattern = \"<part>_HLT01_PartAdder_(.*)\";\n") - f.write(svc+".ServicePattern = \"MON_<part>_hlt01_"+s+"/Counter/\";\n") - f.write(svc+".AdderClass = \"Counter\";\n") - f.write(svc+".ReceiveTimeout = 12;\n") - f.write(svc+".InDNS = "+InDns+";\n") - f.write(svc+".OutDNS = "+OutDns+";\n") - if vnode: - if s in CounterDebugSvcs: - f.write(svc+".DebugOn = true;\n") - if pname == "LHCbA": - f.write(svc+".ReceiveTimeout = 1000000;\n") - f.write("\n") - # Add UI options - ##f.write("//\n// RPC UI options for adders:\n//\n") - ##f.write("ApplicationMgr.ExtSvc += { \"Online::OnlineUISvc/UI\" };\n") - ##f.write("UI.When = \"initialize\";\n") - -tasklist = [] -vnode= VictimNode() -arch = OnlineEnvBase.HltArchitecture -part = OnlineEnvBase.PartitionName -arch = os.getenv("ARCH",arch) -hostdns = False -if arch == "Calib": - hostdns = True -arch = "/group/online/dataflow/architectures/lbDataflowArch_"+arch+".xml" -level = sys.argv[1] -TaskListfromArch(arch, tasklist) -ofile = "" -if len(sys.argv) >= 3: - ofile = sys.argv[2] -if ofile == "": - ofile = "/tmp/AdderOptions.opts" -OptionsfromTasks(tasklist,level,ofile,part,hostdns) diff --git a/Online/FarmConfig/job/TopBusyMon.sh b/Online/FarmConfig/job/TopBusyMon.sh deleted file mode 100755 index b8171fd705a4d17addc115e001d72e4e9b5e6e89..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/TopBusyMon.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -cd /group/online/dataflow/cmtuser -export User_release_area=`pwd`; -export CMTPROJECTPATH=`pwd`:${CMTPROJECTPATH}; -source OnlineRelease/setup.x86_64-centos7-gcc62-dbg.vars -cd OnlineRelease/Online/FarmConfig/job -export msg_svc=LHCb::FmcMessageSvc -export HOST=`hostname` -export UTGID=GEN_${HOST}_BusyMon -export LOGFIFO=/run/fmc/logGaudi.fifo -#export LD_LIBRARY_PATH="/home/beat/cmtuser/OnlineDev_v5r31/InstallArea/x86_64-slc6-gcc49-do0/lib:/group/online/dataflow/cmtuser/OnlineDev_v5r31/InstallArea/x86_64-slc6-gcc49-do0/lib:/cvmfs/lhcb.cern.ch/lib/lcg/releases/Boost/1.59.0_python2.7-682d6/x86_64-slc6-gcc49-dbg/lib:$LD_LIBRARY_PATH" -GaudiOnlineExe.exe libGaudiOnline.so OnlineTask -msgsvc=$msg_svc -tasktype=LHCb::Class2Task -main=/group/online/dataflow/templates/options/Main.opts -opts=../options/TopBsyAdder.opts -auto diff --git a/Online/FarmConfig/job/Tracker.py b/Online/FarmConfig/job/Tracker.py deleted file mode 100755 index 472aaea8de1e97dbe18efb868c870ac96a50d483..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/Tracker.py +++ /dev/null @@ -1,7 +0,0 @@ -import sys -import os -import Criteria -import time -Crits=Criteria.Criteria() -Crits.__init__() -Crits.addTimeInterval([time.mktime(time.strptime("1 Jan 2016","%d %b %Y")),0]) diff --git a/Online/FarmConfig/job/Velo.py b/Online/FarmConfig/job/Velo.py deleted file mode 100755 index 472aaea8de1e97dbe18efb868c870ac96a50d483..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/Velo.py +++ /dev/null @@ -1,7 +0,0 @@ -import sys -import os -import Criteria -import time -Crits=Criteria.Criteria() -Crits.__init__() -Crits.addTimeInterval([time.mktime(time.strptime("1 Jan 2016","%d %b %Y")),0]) diff --git a/Online/FarmConfig/job/VeloCalibMerge.sh b/Online/FarmConfig/job/VeloCalibMerge.sh deleted file mode 100755 index bf63f28de4b006ab718bae2675bcdb786b8dfbc4..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/VeloCalibMerge.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -# -exec -a ${UTGID} ${DATAFLOW_task} -class=Class1 -opts=../options/${TASK_TYPE}.opts; -##exec -a ${UTGID} ${Class1_task} -opts=../options/VeloCalibMerge_Gaudi.opts; diff --git a/Online/FarmConfig/job/VeloCalibWrite.sh b/Online/FarmConfig/job/VeloCalibWrite.sh deleted file mode 100755 index e6e34fe196e3e6b23aedf5ef7f786eb11cd27d36..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/VeloCalibWrite.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -# -export TAN_PORT=YES -export TAN_NODE=${DATAINTERFACE} -# -. /home/frankm/cmtuser/OnlineDev_v6r4/setup.x86_64-centos7-gcc62-do0.vars; -cd ${FARMCONFIGROOT}/job; -exec -a ${UTGID} ${DATAFLOW_task} -class=Class1 -opts=../options/VeloCalibWrite.opts; diff --git a/Online/FarmConfig/job/VeloCalibWriteReg.sh b/Online/FarmConfig/job/VeloCalibWriteReg.sh deleted file mode 100755 index af47ad31d4a65737a9c9a7406fb4c094951031b0..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/VeloCalibWriteReg.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -# -export TAN_PORT=YES -export TAN_NODE=${DATAINTERFACE} -# -exec -a ${UTGID} ${DATAFLOW_task} -class=Class2 -opts=../options/VeloCalibWriteReg.opts; - diff --git a/Online/FarmConfig/job/createEnvironment.sh b/Online/FarmConfig/job/createEnvironment.sh index f8024ee798ffe61676738a9c0381eb7c38f204f8..2ed888ba293838520a1c484296aa6e092abce4d4 100755 --- a/Online/FarmConfig/job/createEnvironment.sh +++ b/Online/FarmConfig/job/createEnvironment.sh @@ -9,6 +9,24 @@ # # ========================================================================= # +export UTGID=${UTGID} +if test -n "${LOGFIFO}"; then + export LOGFIFO=${LOGFIFO}; +fi; +if test -z "${LOGFIFO}" -a -e /dev/shm/logs.dev; then + export LOGFIFO=/dev/shm/logs.dev; +fi; +if test -z "${DIM_DNS_NODE}"; then + if [ -r /etc/sysconfig/dim ]; then + . /etc/sysconfig/dim; + if test "`echo $DIM_DNS_NODE | cut -b 1-5`" = "fmc01"; then + DIM_DNS_NODE=`hostname -s`; + fi; + export DIM_DNS_NODE; + fi; +fi; +export DIM_DNS_NODE; +# export CLASS=Class1; # # Evaluate the information in the runinfo file @@ -129,3 +147,15 @@ except Exception as X: _p('exit 11') EOF` +# +# +setup_options_path() { + if test -n "${1}"; then + export GEN_OPTIONS=/group/online/dataflow/options/${PARTITION}/${1}; + else + export GEN_OPTIONS=/group/online/dataflow/options/${PARTITION}; + fi; + export INFO_OPTIONS=${GEN_OPTIONS}/OnlineEnv.opts; + export PYTHONPATH=${GEN_OPTIONS}:${PYTHONPATH}; + #echo "ERROR: PYTHONPATH=${PYTHONPATH}"; +} diff --git a/Online/FarmConfig/job/preamble.sh b/Online/FarmConfig/job/preamble.sh index abc3946e75c7f24d47c4cfd14c38b7532a185993..528d00270cc685f4270829ed98d9b52499bc2eff 100755 --- a/Online/FarmConfig/job/preamble.sh +++ b/Online/FarmConfig/job/preamble.sh @@ -6,4 +6,22 @@ dataflow_monitoring_options() { echo "-opts=/group/online/dataflow/options/${PARTITION_NAME}/MONITORING/${UTGID}.opts"; } # dataflow_task() -{ echo "exec -a ${UTGID} genRunner.exe libDataflow.so dataflow_run_task -msg=fifo -mon=Dataflow_DIMMonitoring -class=$1"; } +{ + arg_1=${1}; + shift; + echo "exec -a ${UTGID} genRunner.exe libDataflow.so dataflow_run_task -msg=fifo -mon=Dataflow_DIMMonitoring -class=${arg_1} $*"; +} +# +gaudi_task() +{ + arg_1=${1}; + shift; + echo "exec -a ${UTGID} genPython.exe `which gaudirun.py` ${arg_1} --application=OnlineApplication $*"; +} +# +gaudi_event_task() +{ + arg_1=${1}; + shift; + echo "exec -a ${UTGID} genPython.exe `which gaudirun.py` ${arg_1} --application=Online::OnlineEventApp $*"; +} diff --git a/Online/FarmConfig/job/runL0.sh b/Online/FarmConfig/job/runL0.sh deleted file mode 100755 index dc2440a2b8705b34a33f3c96292c2b4362e7f9b8..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/runL0.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -ulimit -v 3221225472 -export UTGID; -export DIM_DNS_NODE=$1 -export PARTITION_NAME=$2 -export NBOFSLAVES=${3:-0} -# remove the args because they interfere with the cmt scripts -export HOME=/home/$(/usr/bin/whoami) -# -. /group/hlt/MOORE/${MOOREONLINE_VERSION}/InstallArea/${CMTCONFIG}/setupMoore.sh; -# -# Enable next line for Debug printout -#python ${FARMCONFIGROOT}/job/ConfigureCheckpoint.py -r ${RUNINFO} -s; -eval `python ${FARMCONFIGROOT}/job/ConfigureCheckpoint.py -r ${RUNINFO} -s -t Moore2`; -renice -n 19 -p $$>>/dev/null -# -if test "${MOORESTARTUP_MODE}" = "RESTORE"; ## RunInfo flag=2 - then - # Enable next line for Debug printout - #python ${FARMCONFIGROOT}/job/ConfigureFromCheckpoint.py; - #echo "RESORE command: ${RESTORE_CMD}"; - eval "python ${FARMCONFIGROOT}/job/ConfigureFromCheckpoint.py | ${RESTORE_CMD}"; -else - exec -a ${UTGID} GaudiCheckpoint.exe libGaudiOnline.so OnlineTask \ - -msgsvc=LHCb::FmcMessageSvc \ - -tasktype=LHCb::Class1Task \ - -main=/group/online/dataflow/templates/options/Main.opts \ - -opt=command="import MooreScripts.runOnline; MooreScripts.runOnline.start(NbOfSlaves = "${NBOFSLAVES}", Split = 'Hlt2', CheckOdin = False, WriterRequires = [ 'Hlt2' ] )" \ - ${APP_STARTUP_OPTS}; -fi; diff --git a/Online/FarmConfig/job/runMooreHlt2Online_EFF.sh b/Online/FarmConfig/job/runMooreHlt2Online_EFF.sh deleted file mode 100755 index 7179f9e94cbd782ffb82d3cf31cfc5562a70bc3f..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/job/runMooreHlt2Online_EFF.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -ulimit -v 3221225472 -export UTGID; -export DIM_DNS_NODE=$1 -export PARTITION_NAME=$2 -export NBOFSLAVES=${3:-0} -# remove the args because they interfere with the cmt scripts -export HOME=/home/$(/usr/bin/whoami) -# -. /group/hlt/MOORE/${MOOREONLINE_VERSION}/InstallArea/${CMTCONFIG}/setupMoore.sh; -# -# Enable next line for Debug printout -#python ${FARMCONFIGROOT}/job/ConfigureCheckpoint.py -r ${RUNINFO} -s -t Moore2; -eval `python ${FARMCONFIGROOT}/job/ConfigureCheckpoint.py -r ${RUNINFO} -s -t Moore2`; -renice 19 -p $$>>/dev/null -# -if test "${MOORESTARTUP_MODE}" = "RESTORE"; ## RunInfo flag=2 - then - # Enable next line for Debug printout - #python ${FARMCONFIGROOT}/job/ConfigureFromCheckpoint.py; - #echo "RESORE command: ${RESTORE_CMD}"; - mkdir -p /tmp/Commands; - python -c "import ConfigureFromCheckpoint" > /tmp/Commands/$$.cmds; - ${RESTORE_CMD} < /tmp/Commands/$$.cmds; - ###eval "python ${FARMCONFIGROOT}/job/ConfigureFromCheckpoint.py | ${RESTORE_CMD}"; -else - exec -a ${UTGID} GaudiCheckpoint.exe libGaudiOnline.so OnlineTask \ - -msgsvc=LHCb::FmcMessageSvc \ - -tasktype=LHCb::Class1Task \ - -main=/group/online/dataflow/templates/options/Main.opts \ - -opt=command="import MooreScripts.runOnline; MooreScripts.runOnline.start(NbOfSlaves = "${NBOFSLAVES}", Split = 'Hlt2', CheckOdin = False, WriterRequires = [ 'Hlt2' ] )" \ - ${APP_STARTUP_OPTS}; -fi; - diff --git a/Online/FarmConfig/job/runTask.sh b/Online/FarmConfig/job/runTask.sh index bc4a2c8a7b207914c783b6278da3b9bc24e0470b..be8e943d62bd6b5df828e16e611579e2506b9657 100755 --- a/Online/FarmConfig/job/runTask.sh +++ b/Online/FarmConfig/job/runTask.sh @@ -35,61 +35,48 @@ export DATAINTERFACE; export ONLINETASKS=/group/online/dataflow/templates; export INFO_OPTIONS=${DYNAMIC_OPTS}/OnlineEnv.opts; export MBM_SETUP_OPTIONS=${DYNAMIC_OPTS}/MBM_setup.opts; -echo "INFO_OPTIONS: ${INFO_OPTIONS}"; -echo "MBM_SETUP_OPTIONS: ${MBM_SETUP_OPTIONS}"; export PYTHONPATH=${DYNAMIC_OPTS}:${PYTHONPATH}; # . ./preamble.sh; # # echo "[ERROR] INFO_OPTIONS=${INFO_OPTIONS}"; # -if test -f ./${TASK_TYPE}.sh; -then - # echo "RunTask: TASK_TYPE: ${TASK_TYPE} ./${TASK_TYPE}.sh" - . ./${TASK_TYPE}.sh $*; - # - # - # -elif test -f ./${PARTITION_NAME}${TASK_TYPE}.sh; -then - # echo "RunTask: TASK_TYPE: ${TASK_TYPE} ./${PARTITION_NAME}${TASK_TYPE}.sh" - . ./${PARTITION_NAME}${TASK_TYPE}.sh; - # +execute() +{ + PRINT_COMMAND_LINE=YES; ####YES; + if test -n "${PRINT_COMMAND_LINE}"; then + echo "[INFO] INFO_OPTIONS: ${INFO_OPTIONS}"; + echo "[INFO] MBM_SETUP_OPTIONS: ${MBM_SETUP_OPTIONS}"; + echo "[INFO] $*"; + fi; + $*; +} +if test -f ./${TASK_TYPE}.sh; then + execute . ./${TASK_TYPE}.sh $*; # +elif test -f ./${PARTITION_NAME}${TASK_TYPE}.sh; then + execute . ./${PARTITION_NAME}${TASK_TYPE}.sh; # -elif test -f ${SMICONTROLLERROOT}/scripts/${TASK_TYPE}.sh; -then - echo "${SMICONTROLLERROOT}/scripts/${TASK_TYPE}.sh"; +elif test -f ${SMICONTROLLERROOT}/scripts/${TASK_TYPE}.sh; then cd ${SMICONTROLLERROOT}/scripts; - . ${SMICONTROLLERROOT}/scripts/${TASK_TYPE}.sh; - # - # + execute . ${SMICONTROLLERROOT}/scripts/${TASK_TYPE}.sh; # elif test -f "${OPTIONS}"; then - # echo "RunTask: TASK_TYPE: ${TASK_TYPE} Options: ${OPTIONS}" - `dataflow_task ${CLASS}` -opts=${OPTIONS} ${AUTO_STARTUP} ${DEBUG_STARTUP} - # - # + execute `dataflow_task ${CLASS}` -opts=${OPTIONS} ${AUTO_STARTUP} ${DEBUG_STARTUP}; # elif test -f "${STATIC_OPTS}/${TASK_TYPE}.opts"; then - # echo "RunTask: TASK_TYPE: ${TASK_TYPE} Options: ${STATIC_OPTS}/${TASK_TYPE}.opts" - `dataflow_task ${CLASS}` -opts=${STATIC_OPTS}/${TASK_TYPE}.opts ${AUTO_STARTUP} ${DEBUG_STARTUP}; - # + execute `dataflow_task ${CLASS}` -opts=${STATIC_OPTS}/${TASK_TYPE}.opts ${AUTO_STARTUP} ${DEBUG_STARTUP}; # +elif test -f "${STATIC_OPTS}/${TASK_TYPE}.py"; then + execute `gaudi_task ${STATIC_OPTS}/${TASK_TYPE}.py`; # elif test -n "`echo ${UTGID} | grep TestEvent`"; then - #echo "`which gaudirun.py` ${SMICONTROLLERROOT}/scripts/EventProcessor.py --application=OnlineEvents"; - exec -a ${UTGID} genPython.exe `which gaudirun.py` ${SMICONTROLLERROOT}/scripts/EventProcessor.py --application=OnlineEvents; - # + execute `gaudi_event_task ${SMICONTROLLERROOT}/scripts/EventProcessor.py`; # +elif test -f ./${PARTITION_NAME}DefaultTask.sh; then + execute . ./${PARTITION_NAME}DefaultTask.sh; # -elif test -f ./${PARTITION_NAME}DefaultTask.sh; -then - # echo "RunTask: TASK_TYPE: ${TASK_TYPE} ./${PARTITION_NAME}DefaultTask.sh" - . ./${PARTITION_NAME}DefaultTask.sh; else - # echo "RunTask: TASK_TYPE: ${TASK_TYPE} ./DefaultTask.sh" - # . ./DefaultTask.sh; cd ${SMICONTROLLERROOT}/scripts; - exec -a ${UTGID} genPython.exe ${SMICONTROLLERROOT}/scripts/DummyTask.py -utgid ${UTGID} -partition 103 -print ${OUTPUT_LEVEL}; + execute exec -a ${UTGID} genPython.exe ${SMICONTROLLERROOT}/scripts/DummyTask.py -utgid ${UTGID} -partition 103 -print ${OUTPUT_LEVEL}; fi; diff --git a/Online/FarmConfig/options/AddTest_EMPTY.opts b/Online/FarmConfig/options/AddTest_EMPTY.opts deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/Online/FarmConfig/options/AddTest_Victim.opts b/Online/FarmConfig/options/AddTest_Victim.opts deleted file mode 100644 index b5c5a3efbff39dc6378ab8a51a613f86169723f1..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/AddTest_Victim.opts +++ /dev/null @@ -1,4 +0,0 @@ -//Moore2CountAdder.Test = true; -//Moore2CountAdder.DebugOn = true; -//Moore1CountAdder.Test = true; -//HLT2SenderAdder.Test = true; diff --git a/Online/FarmConfig/options/BasicDiskReader.opts b/Online/FarmConfig/options/BasicDiskReader.opts deleted file mode 100755 index ba185dde413c6ec160f316ae9e95bc998859e615..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/BasicDiskReader.opts +++ /dev/null @@ -1,23 +0,0 @@ -#include "$INFO_OPTIONS" -#include "$MBM_SETUP_OPTIONS" -#include "$STATIC_OPTS/SvcMapping.opts" -#include "$STATIC_OPTS/Monitoring.opts" -// -ApplicationMgr.Runable = "LHCb::HltBufferedIOReader/Runable"; -ApplicationMgr.EventLoop = "LHCb::OnlineRunable/EventLoopMgr"; -ApplicationMgr.EvtSel = "NONE"; -ApplicationMgr.HistogramPersistency = "NONE"; -// -EventLoopMgr.Wait = 1; -// -Runable.DeleteFiles = true; -Runable.Directory = "/localdisk/overflow"; -Runable.AllowedRuns = @OnlineEnv.DeferredRuns; -Runable.BrokenHosts = ""; -// -MEPManager.PartitionID = @OnlineEnv.PartitionID; -MEPManager.PartitionName = @OnlineEnv.PartitionName; -MEPManager.PartitionBuffers = @OnlineEnv.PartitionBuffers; -MEPManager.ConnectWhen = "initialize"; -// -#include "$STATIC_OPTS/MessageSvc.opts" diff --git a/Online/FarmConfig/options/Checkpoint.opts b/Online/FarmConfig/options/Checkpoint.opts deleted file mode 100755 index 8536e0db99507b72b81d4681085bfdd4c18f0293..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/Checkpoint.opts +++ /dev/null @@ -1,17 +0,0 @@ -// These are the defaults on the HLT farm -CheckpointSvc.Partition = @OnlineEnv.PartitionName; -CheckpointSvc.FirstChild = 0; -CheckpointSvc.ChildSleep = 100; -//CheckpointSvc.MaxChildren = 40; -CheckpointSvc.TaskType = "$TASK_TYPE"; -//CheckpointSvc.UtgidPattern = "%P_%NN_%T_%02d"; -CheckpointSvc.UtgidPattern = "%UTGID%02d"; -CheckpointSvc.UseCores = false; -CheckpointSvc.DumpFiles = false; -CheckpointSvc.PrintLevel = 4; -CheckpointSvc.OutputLevel = @OnlineEnv.OutputLevel; -// If the number of instances < 0: take the true number from the environment -// Value is overwritten for restart after checkpoint. -// CheckpointSvc.NumberOfInstances = -1; -CheckpointSvc.NumberOfInstances = "$NBOFSLAVES"; -CheckpointSvc.DeclareStateOnPAUSE = true; diff --git a/Online/FarmConfig/options/CheckpointRestart.opts b/Online/FarmConfig/options/CheckpointRestart.opts deleted file mode 100755 index 71133bd682d88823225ed73cb7c084ae219f97a9..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/CheckpointRestart.opts +++ /dev/null @@ -1,12 +0,0 @@ -// -// Options necessary to restart from the checkpoint file. -// -#include "$PARTITIONOPTS" -MEPManager.PartitionID = @OnlineEnv.PartitionID; -MEPManager.PartitionName = @OnlineEnv.PartitionName; -MessageSvc.OutputLevel = @OnlineEnv.OutputLevel; -//MessageSvc.doPrintAlways = False; -#include "$CHECKPOINT_SETUP_OPTIONS" -CheckpointSvc.NumberOfInstances = "$NUMBER_OF_CHILDREN"; -CheckpointSvc.ExitAfterCheckpoint = false; - diff --git a/Online/FarmConfig/options/DWHiMu.opts b/Online/FarmConfig/options/DWHiMu.opts deleted file mode 100644 index bf8a37afba1c8772b21a6ed97474a86340925a74..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/DWHiMu.opts +++ /dev/null @@ -1,37 +0,0 @@ -// MSF: 04/12/2016: NEW Dataflow task type ! -#pragma print off -//------------- Default Writer options: ------------------------------------------ -#include "$INFO_OPTIONS" -#include "$MBM_SETUP_OPTIONS" -#include "../options/Monitoring.opts" -Manager.Services = {"Dataflow_MBMClient/MBM", - "Dataflow_FileWriter/DskWriter", -// "Dataflow_LumiCounter/LumiCounter", - "Dataflow_FileWriterMgr/WrManager", - "Dataflow_RunableWrapper/Wrap" - }; -Manager.Runable = "Wrap"; -Wrap.Callable = "WrManager"; -// -MBM.PartitionBuffers = @OnlineEnv.PartitionBuffers; -MBM.PartitionName = @OnlineEnv.PartitionName; -MBM.PartitionID = @OnlineEnv.PartitionID; -MBM.Buffers = @OnlineEnv.DWHiMu_Buffers; -// -WrManager.Processors += {"DskWriter"}; -//WrManager.Processors += {"LumiCounter"}; -WrManager.Input = @OnlineEnv.DWHiMu_Input; -DskWriter.SizeLimit = 200; -DskWriter.Requirements = { -"EvType=2;TriggerMask=0xffffffff,0xffffffff,0xffffffff,0xffffffff;VetoMask=0,0,0,0;MaskType=ANY;UserType=VIP;Frequency=PERC;Perc=100.0" -}; -DskWriter.DeviceList = {"/localdisk1", "/localdisk2"}; -DskWriter.FilePrefix = "/hlt1/Run_"; -// -LumiCounter.Requirements = { -"EvType=2;TriggerMask=0x0,0x2,0x0,0x0;VetoMask=0,0,0,0;MaskType=ANY;UserType=VIP;Frequency=PERC;Perc=100.0" -}; -LumiCounter.BackupFile = "LumiCounter2017.file"; -LumiCounter.DontCloseRuns = true; -Logger.OutputLevel = @OnlineEnv.OutputLevel; -Monitoring.CounterUpdateInterval = 5; diff --git a/Online/FarmConfig/options/Daemon.opts b/Online/FarmConfig/options/Daemon.opts deleted file mode 100755 index 662b21b211de974ea2853215a9fc9a45172674ce..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/Daemon.opts +++ /dev/null @@ -1,5 +0,0 @@ -#pragma print off -#include "$GAUDIONLINEROOT/options/Main.opts" -Runable.Wait = 3; -ApplicationMgr.ExtSvc = {"IncidentSvc"}; -MessageSvc.OutputLevel = 4; // Minimum is Warning diff --git a/Online/FarmConfig/options/DefHLT2Reader.opts b/Online/FarmConfig/options/DefHLT2Reader.opts deleted file mode 100755 index eb7477bf6ead627e7424145eaff86a1dacaa6801..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/DefHLT2Reader.opts +++ /dev/null @@ -1,17 +0,0 @@ -#include "$FARMCONFIGROOT/options/BasicDiskReader.opts" -#include "$NODE_OPTIONS" -MEPManager.Buffers = @OnlineEnv.LHCb1Reader_Buffers; -MEPManager.Buffers = @OnlineEnv.Moore2_Buffers; -Runable.Directory = ""; -Runable.Directories = {"/localdisk1/hlt1_KEEP", "/localdisk2/hlt1_KEEP"}; -Runable.FilePrefix = "Run_"; -Runable.Buffer = @OnlineEnv.Hlt2Reader_Output; -Runable.DeleteFiles = false; -Runable.Rescan = false; -Runable.InitialSleep = 0; -// Runable.GoService = "$GO_SERVICE_NAME"; -Runable.PauseSleep = 5; // Optional wait time until 'Output' event queue is empty -Runable.CheckedBuffers = @OnlineEnv.Moore2_Buffers; -MessageSvc.OutputLevel = 3; -// Only for hlt1_KEEP data of 2015 -Runable.AllowedRuns = {167023}; diff --git a/Online/FarmConfig/options/DefMoore2.opts b/Online/FarmConfig/options/DefMoore2.opts deleted file mode 100755 index ae17a3ac87e8d0697c28500ade812dc9f0beed1c..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/DefMoore2.opts +++ /dev/null @@ -1,6 +0,0 @@ -#include "$STATIC_OPTS/Moore_Passthrough.opts" -MEPManager.Buffers = @OnlineEnv.Moore2_Buffers; -Merger.Buffer = @OnlineEnv.Moore2_Output; -EventSelector.Decode = false; // Reading MDF banks from MBM. No decoding necessary -EventSelector.Input = @OnlineEnv.Moore2_Input; -EventSelector.REQ1 = "EvType=2;TriggerMask=0xffffffff,0xffffffff,0xffffffff,0xffffffff;VetoMask=0,0,0,0;MaskType=ANY;UserType=ONE;Frequency=PERC;Perc=100.0"; diff --git a/Online/FarmConfig/options/DskReader.opts b/Online/FarmConfig/options/DskReader.opts deleted file mode 100755 index 4fab3adff620e6845cca04226bdb6282e3d33764..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/DskReader.opts +++ /dev/null @@ -1,9 +0,0 @@ -#include "$FARMCONFIGROOT/options/BasicDiskReader.opts" -#include "$NODE_OPTIONS" -Runable.Directory = "/localdisk/hlt1"; -Runable.FilePrefix = "Run_"; -Runable.Buffer = @OnlineEnv.DskReader_Output; -MEPManager.Buffers = @OnlineEnv.DskReader_Buffers; -Runable.DeleteFiles = true; -Runable.InitialSleep = 0; - diff --git a/Online/FarmConfig/options/DskWriter.opts b/Online/FarmConfig/options/DskWriter.opts deleted file mode 100755 index 6831e904c6e641681b48eaf37cd76ca56c5b8320..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/DskWriter.opts +++ /dev/null @@ -1,39 +0,0 @@ -// MSF: 04/12/2016: NEW Dataflow task type ! -#pragma print off -//------------- Default Writer options: ------------------------------------------ -#include "$INFO_OPTIONS" -#include "$MBM_SETUP_OPTIONS" -#include "../options/Monitoring.opts" -Manager.Services = {"Dataflow_MBMClient/MBM", - "Dataflow_FileWriter/DskWriter", - "Dataflow_LumiCounter/LumiCounter", - "Dataflow_FileWriterMgr/WrManager", - "Dataflow_RunableWrapper/Wrap", - "Dataflow_UI/UI" - }; -Manager.Runable = "Wrap"; -Wrap.Callable = "WrManager"; -// -MBM.PartitionBuffers = @OnlineEnv.PartitionBuffers; -MBM.PartitionName = @OnlineEnv.PartitionName; -MBM.PartitionID = @OnlineEnv.PartitionID; -MBM.Buffers = @OnlineEnv.DskWriter_Buffers; -// -WrManager.Processors += {"DskWriter"}; -WrManager.Processors += {"LumiCounter"}; -WrManager.Input = @OnlineEnv.DskWriter_Input; -DskWriter.SizeLimit = 200; -//DskWriter.NodePattern = "hlt[a-z][0-1][0-9](.*)"; -DskWriter.Requirements = { -"EvType=2;TriggerMask=0xffffffff,0xffffffff,0xffffffff,0xffffffff;VetoMask=0,0,0,0;MaskType=ANY;UserType=VIP;Frequency=PERC;Perc=100.0" -}; -DskWriter.DeviceList = {"/localdisk1", "/localdisk2"}; -DskWriter.FilePrefix = "/hlt1/Run_"; -// -LumiCounter.Requirements = { -"EvType=2;TriggerMask=0x0,0x2,0x0,0x0;VetoMask=0,0,0,0;MaskType=ANY;UserType=VIP;Frequency=PERC;Perc=100.0" -}; -LumiCounter.BackupFile = "LumiCounter2018.file"; -LumiCounter.DontCloseRuns = true; -Logger.OutputLevel = @OnlineEnv.OutputLevel; -Monitoring.CounterUpdateInterval = 5; diff --git a/Online/FarmConfig/options/DummyDaemon.opts b/Online/FarmConfig/options/DummyDaemon.opts deleted file mode 100755 index 570f4bbb4d84808c4e1e7d9d3e1dfb1ca2b37751..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/DummyDaemon.opts +++ /dev/null @@ -1,7 +0,0 @@ -#pragma print off -#include "$GAUDIONLINEROOT/options/Main.opts" -Runable.Wait = 3; -ApplicationMgr.ExtSvc = {"IncidentSvc"}; -MessageSvc.OutputLevel = 4; // Minimum is Warning -ApplicationMgr.TopAlg += {"LHCb::PausAlg/Pause"}; -Pause.Timeout = 15; diff --git a/Online/FarmConfig/options/DummyDataflow.opts b/Online/FarmConfig/options/DummyDataflow.opts deleted file mode 100755 index 425703f81c9dfddecccb7e7cf4e5930d65778a5e..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/DummyDataflow.opts +++ /dev/null @@ -1,9 +0,0 @@ -#pragma print off -//------------- Default sender options: ------------------------------------------ -#include "$INFO_OPTIONS" -#include "$FARMCONFIGROOT/options/Monitoring.opts" - -Manager.Services = {}; -Logger.OutputLevel = @OnlineEnv.OutputLevel; -Logger.OutputLevel = 1; -Monitoring.CounterUpdateInterval = 5; diff --git a/Online/FarmConfig/options/DummyTask.opts b/Online/FarmConfig/options/DummyTask.opts deleted file mode 100755 index c7392f16a86f9cec5724ee0fdc4d4edace66e113..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/DummyTask.opts +++ /dev/null @@ -1,23 +0,0 @@ -// ======================================================================================= -// Dummy task processing NO events -// -// Use to test new services etc. -// -// \author M.Frank -// \date 02/02/2015 -// -// ======================================================================================= -#include "$INFO_OPTIONS" -#include "$STATIC_OPTS/SvcMapping.opts" -#include "$STATIC_OPTS/Monitoring.opts" -ApplicationMgr.EventLoop = "LHCb::OnlineRunable/EmptyEventLoop"; -ApplicationMgr.Runable = "LHCb::OnlineRunable/Runable"; -ApplicationMgr.HistogramPersistency = "NONE"; -ApplicationMgr.EvtSel = "NONE"; -//ApplicationMgr.ExtSvc += {"LHCb::IncidentProvoker/Pause"}; -//Pause.Incident = "DAQ_ERROR"; -//Pause.Incident = "DAQ_PAUSE"; -//Pause.Timeout = 10; -Runable.Wait = 3; // 1 of running as daemon -MessageSvc.OutputLevel = 1; //@OnlineEnv.OutputLevel; -IncidentSvc.OutputLevel = 4; diff --git a/Online/FarmConfig/options/EBMBM.opts b/Online/FarmConfig/options/EBMBM.opts index 45a8530bf38d7456d2a068db9a6a43409a7065fa..4b273e267b3de78582597c6597c2b6ef9bd80193 100644 --- a/Online/FarmConfig/options/EBMBM.opts +++ b/Online/FarmConfig/options/EBMBM.opts @@ -6,4 +6,4 @@ Manager.Setup = {"Dataflow_MBMServer/MEPManager"}; Manager.Services = {"Dataflow_UI/UI"}; MEPManager.PartitionBuffers = true; MEPManager.PartitionName = @OnlineEnv.PartitionName; -MEPManager.InitFlags = "-s=35000000 -e=150 -u=20 -b=12 -t=1 -n=0 -f -i=Events_0 -c -s=35000000 -e=150 -u=20 -b=12 -t=1 -n=1 -f -i=Events_1 -c -s=500000 -e=150 -u=5 -b=12 -t=1 -f -i=Output -c"; +MEPManager.InitFlags = "-s=5000000 -e=150 -u=20 -b=12 -t=1 -n=0 -f -i=Events_0 -c -s=5000000 -e=150 -u=20 -b=12 -t=1 -n=1 -f -i=Events_1 -c -s=500000 -e=150 -u=5 -b=12 -t=1 -f -i=Output -c"; diff --git a/Online/FarmConfig/options/EBReader.opts b/Online/FarmConfig/options/EBReader.opts new file mode 100644 index 0000000000000000000000000000000000000000..b4a38880fb1d7af3453c16145bcac5d2a5b62251 --- /dev/null +++ b/Online/FarmConfig/options/EBReader.opts @@ -0,0 +1,51 @@ +#pragma print off +#include "$INFO_OPTIONS" +#include "$FARMCONFIGROOT/options/Logging.opts" +#include "$FARMCONFIGROOT/options/Monitoring.opts" +// +Manager.Services = {"Dataflow_MBMClient/MEPManager", + "Dataflow_DiskReader/Reader", +// "Dataflow_StorageReader/Reader", + "Dataflow_RunableWrapper/Wrap", + "Dataflow_UI/UI" + }; +Manager.Runable = "Wrap"; +Wrap.Callable = "Reader"; +Task.HavePause = true; +// +Reader.Buffer = "$MBM_OUTPUT_BUFFER"; +Reader.BrokenHosts = ""; +Reader.Directories = {"/group/online/dataflow/cmtuser/data/mdf", + "/group/online/dataflow/cmtuser/data/tae" + }; +Reader.FilePrefix = "file_"; +// +Reader.AllowedRuns = {"*"}; +Reader.MuDelay = 0; +Reader.DeleteFiles = false; +Reader.SaveRest = false; +Reader.PauseSleep = 2; // Optional wait time until 'Output' event queue is empty +Reader.InitialSleep = 0; +Reader.MaxPauseWait = 1; +Reader.GoService = ""; +Reader.Rescan = 1; +Reader.RequireConsumers = 0; +Reader.MMapFiles = 0; +Reader.ReuseFile = 0; +Reader.PackingFactor = 2000; +Reader.AllocationSizekB = 20000; +Reader.PatchOdin = 5000000; +Reader.RunNumberService = ""; +// +MEPManager.PartitionBuffers = true; +MEPManager.PartitionName = @OnlineEnv.PartitionName; +MEPManager.PartitionID = @OnlineEnv.PartitionID; +MEPManager.Buffers = {"$MBM_OUTPUT_BUFFER"}; +/* +Reader.PartitionName = "LHCb"; +Reader.Directories = {""}; +Reader.FilePrefix = "file:/daqarea1/objects/nfs_data/${PARTITION}/HLT1/${RUN1000}/${RUN}/Run_"; +Reader.AllowedRuns = {"72908"}; +Reader.DataType = "posix"; +Reader.Server = "XXEB09.lbdaq.cern.ch:8000"; +*/ diff --git a/Online/FarmConfig/options/HLT1Sender.opts b/Online/FarmConfig/options/EBSender.opts similarity index 100% rename from Online/FarmConfig/options/HLT1Sender.opts rename to Online/FarmConfig/options/EBSender.opts diff --git a/Online/FarmConfig/options/EBStorage.opts b/Online/FarmConfig/options/EBStorage.opts index 4a9f9b46e725d6fa359b62f90cb15f5fcd9e35a6..f2961e8b2b6efa34571be547a42e60a0e0cb5a12 100644 --- a/Online/FarmConfig/options/EBStorage.opts +++ b/Online/FarmConfig/options/EBStorage.opts @@ -1,43 +1,10 @@ -#pragma print off -#include "$INFO_OPTIONS" -#include "$FARMCONFIGROOT/options/Logging.opts" -#include "$FARMCONFIGROOT/options/Monitoring.opts" -// -Manager.Services = {"Dataflow_MBMClient/MBM", - "Dataflow_MBMSelector/EventProc", - "Dataflow_RunableWrapper/Wrap" - }; -Manager.Algorithms = {"Dataflow_EmptyProcessor/Empty"}; -Manager.Runable = "Wrap"; -Wrap.Callable = "EventProc"; -// -EventProc.REQ1 = "EvType=1;TriggerMask=0xffffffff,0xffffffff,0xffffffff,0xffffffff;VetoMask=0,0,0,0;MaskType=ANY;UserType=USER;Frequency=PERC;Perc=100.0"; -EventProc.REQ2 = "EvType=2;TriggerMask=0xffffffff,0xffffffff,0xffffffff,0xffffffff;VetoMask=0,0,0,0;MaskType=ANY;UserType=USER;Frequency=PERC;Perc=100.0"; -// -EventProc.Input = "Output"; -// -OnlineEnv.PartitionBuffers = true; -MBM.PartitionBuffers = @OnlineEnv.PartitionBuffers; -MBM.PartitionName = @OnlineEnv.PartitionName; -MBM.PartitionID = @OnlineEnv.PartitionID; -MBM.Buffers = {"Output"}; -// -// -Manager.Algorithms = {"Dataflow_StorageWriter/Writer"}; -Writer.PartitionName = @OnlineEnv.PartitionName; -//Writer.Activity = @OnlineEnv.Activity; -Writer.RunType = @OnlineEnv.RunType; -Writer.FileName = "/objects/data/testing/${RUN1000}/${RUN}/Run_${RUN}_${NODE}_${TIME}_${SEQ}.mdf"; +#include "$DATAFLOWROOT/options/StorageWriter.opts" +Writer.BufferSizeMB = 4000; +Writer.MaxFileSizeMB = -1; // Only valid for posix writing +Writer.NumBuffers = 4; +Writer.NumThreads = 3; +Writer.Stream = "Full"; Writer.Server = "XXEB09.lbdaq.cern.ch:8000"; -Writer.FileSizeMB = 500; -Writer.MinFileSizeMB = 10; -Writer.WriteErrorRetry = 100000; -Writer.WriteErrorSleep = 3000; -Writer.PollTimeout = 100000; // micro-seconds -Writer.NumBuffers = 6; -Writer.NumThreads = 4; -Writer.CancelTimeout = 100; // seconds -Writer.ForceMDF = true; -// -Logger.OutputLevel = 0; +Writer.FileName = "/objects/data/HLT1/${PARTITION}/${STREAM}/${RUN1000}/${RUN}/Run_${RUN}_${NODE}_${TIME}_${PID}_${SEQ}.mdf"; // +EventProc.REQ2 = "EvType=2;TriggerMask=0xffffffff,0xffffffff,0xffffffff,0xffffffff;VetoMask=0,0,0,0;MaskType=ANY;UserType=VIP;Frequency=PERC;Perc=20.0"; diff --git a/Online/FarmConfig/options/FileRawSizeMon.opts b/Online/FarmConfig/options/FileRawSizeMon.opts deleted file mode 100755 index 8da5b04da7bce06555bc881b790b8f971a1ddbc9..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/FileRawSizeMon.opts +++ /dev/null @@ -1,50 +0,0 @@ -// ======================================================================================= -// Dummy task processing NO events -// -// Use to test new services etc. -// -// \author M.Frank -// \date 02/02/2015 -// -// ======================================================================================= -#pragma print off -#include "$INFO_OPTIONS" -#include "$STATIC_OPTS/SvcMapping.opts" -#include "$STATIC_OPTS/Monitoring.opts" -ApplicationMgr.HistogramPersistency ="NONE"; -ApplicationMgr.ExtSvc += { "LHCb::FILEEvtSelector/EventSelector" }; -ApplicationMgr.Runable = "LHCb::EventRunable/Runable"; -EventDataSvc.RootCLID = 1; -EventDataSvc.EnableFaultHandler = true ; -EventPersistencySvc.CnvServices = {"LHCb::RawDataCnvSvc/RawDataCnvSvc" }; -#include "$ONLINETASKS/options/MessageSvc.opts" -ApplicationMgr.TopAlg = { "LHCb::DelaySleepAlg/Delay", "UpdateAndReset","LHCb::RawBankSizes/RawBankSizes" }; -Delay.DelayTime = 0; -//Delay.InitializeDelay = 100000; -//Delay.StartDelay = 100000000; -RawBankSizes.number_ofRMS = 10; -RawBankSizes.Bins = 100; -#include "/group/online/dataflow/templates/options/RawSize_Detectors.opts" -#include "/group/online/dataflow/templates/options/RawSize_HistParams.opts" -// -// Customize UpdateAndreset -// -UpdateAndReset.MyName = "$UTGID"; -UpdateAndReset.saveHistograms = 1; -UpdateAndReset.saverCycle = 900000; // No intermediate saving -UpdateAndReset.saveSetDir = "/hist/Savesets"; -UpdateAndReset.saveSetDir = "/home/frankm/cmtuser/Online_v5r14/Online/Controller/cmt/Savesets"; -// -// Customize monitoring service -// -MonitorSvc.ExpandCounterServices = 0; -MonitorSvc.PartitionName = "FEST"; -MonitorSvc.ExpandNameInfix = "<part>_x_<program>/"; -MonitorSvc.ProgramName = "$TASK_TYPE"; -// -// Event selector setup: -// -//MessageSvc.OutputLevel = 1; -EventSelector.Decode = false; -EventSelector.Pause = true; -#include "$EVENTSELECTOR_OPTIONS" diff --git a/Online/FarmConfig/options/HLT2LumiCounter.opts b/Online/FarmConfig/options/HLT2LumiCounter.opts deleted file mode 100755 index 4e54e7553f9069427c9836a887ab57a58339f7c8..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/HLT2LumiCounter.opts +++ /dev/null @@ -1,32 +0,0 @@ -// MSF: 04/12/2016: NEW Dataflow task type ! -#pragma print off -//------------- Default sender options: ------------------------------------------ -#include "$INFO_OPTIONS" -#include "$MBM_SETUP_OPTIONS" -#include "$SUBFARM_OPTIONS" -#include "$FARMCONFIGROOT/options/Monitoring.opts" - -Manager.Services = {"Dataflow_MBMClient/MBM", -// "Dataflow_MBMSelector/EventSelector" - "Dataflow_LumiCounter/LumiCounter", - "Dataflow_FileWriterMgr/WrManager", - "Dataflow_RunableWrapper/Wrap" - }; -Manager.Runable = "Wrap"; -Wrap.Callable = "WrManager"; - -MBM.Buffers = @OnlineEnv.HLT2LumiCounter_Buffers; -MBM.PartitionID = @OnlineEnv.PartitionID; -MBM.PartitionName = @OnlineEnv.PartitionName; -MBM.PartitionBuffers = @OnlineEnv.PartitionBuffers; -WrManager.Input = @OnlineEnv.HLT2LumiCounter_Input; -WrManager.Requirement = "EvType=2;TriggerMask=0xffffffff,0xffffffff,0xffffffff,0xffffffff;VetoMask=0,0,0,0;MaskType=ANY;UserType=VIP;Frequency=PERC;Perc=100.0"; -Logger.OutputLevel = @OnlineEnv.OutputLevel; -Monitoring.CounterUpdateInterval = 5; -LumiCounter.Requirements = { -"EvType=2;TriggerMask=0x0,0x0,0x40000000,0x0;VetoMask=0,0,0,0xb00;MaskType=ANY;UserType=VIP;Frequency=PERC;Perc=100.0" -//"EvType=2;TriggerMask=0x0,0x2,0x0,0x0;VetoMask=0,0,0,0;MaskType=ANY;UserType=VIP;Frequency=PERC;Perc=100.0" -}; -LumiCounter.BackupDirectory = "/localdisk/CounterFiles/"; -LumiCounter.BackupFile = "LumiCounterHLT2-2017.file"; -LumiCounter.DontCloseRuns = true; diff --git a/Online/FarmConfig/options/MEPInit.opts b/Online/FarmConfig/options/HLT2MBM.opts old mode 100755 new mode 100644 similarity index 65% rename from Online/FarmConfig/options/MEPInit.opts rename to Online/FarmConfig/options/HLT2MBM.opts index d09cc5b1d2e48cc42d9eefd17aa27624eaef2781..7388e7aba4c260e0e6d894ecb8479bd0f3d5053b --- a/Online/FarmConfig/options/MEPInit.opts +++ b/Online/FarmConfig/options/HLT2MBM.opts @@ -1,9 +1,12 @@ #pragma print off #include "$INFO_OPTIONS" #include "$MBM_SETUP_OPTIONS" +#include "$FARMCONFIGROOT/options/Logging.opts" +//OnlineEnv.MBM_setup = "-s=1000000 -e=50 -u=30 -b=18 -t=1 -y -i=Events -f -c -s=100000 -e=50 -u=15 -b=12 -t=1 -y -i=Output -f -c"; +// Manager.Setup = {"Dataflow_MBMServer/MEPManager"}; Manager.Services = {"Dataflow_UI/UI"}; +// MEPManager.PartitionBuffers = @OnlineEnv.PartitionBuffers; MEPManager.PartitionName = @OnlineEnv.PartitionName; MEPManager.InitFlags = @OnlineEnv.MBM_setup; -Logger.OutputLevel = @OnlineEnv.OutputLevel; diff --git a/Online/FarmConfig/options/HLT2Reader.opts b/Online/FarmConfig/options/HLT2Reader.opts new file mode 100644 index 0000000000000000000000000000000000000000..e967a4c994b9cabfa803c1a4dfab00b2f9797282 --- /dev/null +++ b/Online/FarmConfig/options/HLT2Reader.opts @@ -0,0 +1,59 @@ +#pragma print off +#include "$INFO_OPTIONS" +#include "$FARMCONFIGROOT/options/Logging.opts" +#include "$FARMCONFIGROOT/options/Monitoring.opts" +// +Manager.Services = {"Dataflow_MBMClient/MEPManager", +// "Dataflow_BurstReader/Reader", + "Dataflow_StorageReader/Reader", + "Dataflow_RunableWrapper/Wrap", + "Dataflow_UI/UI" + }; +Manager.Runable = "Wrap"; +Wrap.Callable = "Reader"; +Task.HavePause = true; +// +Reader.Buffer = "Events"; +Reader.BrokenHosts = ""; +Reader.Directories = {"/home/frankm/data"}; +Reader.FilePrefix = "fakeMDF_"; +Reader.Directories = {"/daqarea1/fest/mdf"}; +// Take the first 100 files: 00135282_000000XX_X.mdf +Reader.FilePrefix = "00135282_0000000"; +// +Reader.Directories = {"/daqarea1/fest/mdf"}; +Reader.FilePrefix = "00135"; +// +Reader.Directories = {"/group/online/dataflow/cmtuser/data/mdf", + "/group/online/dataflow/cmtuser/data/tae" + }; +Reader.FilePrefix = "file_"; +// +Reader.AllowedRuns = {"*"}; +Reader.MuDelay = 0; +Reader.DeleteFiles = false; +Reader.SaveRest = false; +Reader.PauseSleep = 2; // Optional wait time until 'Output' event queue is empty +Reader.InitialSleep = 0; +Reader.MaxPauseWait = 1; +Reader.GoService = ""; +Reader.Rescan = 1; +Reader.RequireConsumers = 0; +Reader.MMapFiles = 0; +Reader.ReuseFile = 0; +Reader.PackingFactor = 2000; +Reader.AllocationSizekB = 20000; +Reader.PatchOdin = 5000000; +// +MEPManager.PartitionBuffers = true; +MEPManager.PartitionName = @OnlineEnv.PartitionName; +MEPManager.PartitionID = @OnlineEnv.PartitionID; +MEPManager.Buffers = {"Events"}; + +Reader.PartitionName = "LHCb"; +Reader.Directories = {""}; +Reader.FilePrefix = "file:/daqarea1/objects/nfs_data/${PARTITION}/HLT1/${RUN1000}/${RUN}/Run_"; +Reader.AllowedRuns = {"72908"}; +Reader.DataType = "posix"; +Reader.Server = "XXEB09.lbdaq.cern.ch:8000"; +// diff --git a/Online/FarmConfig/options/HLT2Writer.opts b/Online/FarmConfig/options/HLT2Writer.opts new file mode 100644 index 0000000000000000000000000000000000000000..90125daa0b1b56aebb740c19f49d5f4f9add3161 --- /dev/null +++ b/Online/FarmConfig/options/HLT2Writer.opts @@ -0,0 +1,10 @@ +#include "$DATAFLOWROOT/options/StorageWriter.opts" +Writer.BufferSizeMB = 4000; +Writer.MaxFileSizeMB = -1; // Only valid for posix writing +Writer.NumBuffers = 4; +Writer.NumThreads = 3; +Writer.Stream = "Full"; +Writer.Server = "XXEB09.lbdaq.cern.ch:8000"; +Writer.FileName = "/objects/data/HLT2/${PARTITION}/${STREAM}/${RUN1000}/${RUN}/Run_${RUN}_${NODE}_${TIME}_${PID}_${SEQ}.mdf"; +// +EventProc.REQ2 = "EvType=2;TriggerMask=0xffffffff,0xffffffff,0xffffffff,0xffffffff;VetoMask=0,0,0,0;MaskType=ANY;UserType=VIP;Frequency=PERC;Perc=20.0"; diff --git a/Online/FarmConfig/options/HLT2WriterPosix.opts b/Online/FarmConfig/options/HLT2WriterPosix.opts new file mode 100644 index 0000000000000000000000000000000000000000..24f0b0f5228c935b5b2aab1b8672b329f64b8f04 --- /dev/null +++ b/Online/FarmConfig/options/HLT2WriterPosix.opts @@ -0,0 +1,8 @@ +#include "$DATAFLOWROOT/options/StorageWriter.opts" +Writer.MaxFileSizeMB = 4000; +Writer.NumBuffers = 6; +Writer.NumThreads = 4; +Writer.Server = "XXEB09.lbdaq.cern.ch:8000"; +Writer.FileName = "/objects/data/HLT2/${PARTITION}/${STREAM}/${RUN1000}/${RUN}/Run_${RUN}_${NODE}_${TIME}_${PID}_${SEQ}.mdf"; +// +EventProc.REQ2 = "EvType=2;TriggerMask=0xffffffff,0xffffffff,0xffffffff,0xffffffff;VetoMask=0,0,0,0;MaskType=ANY;UserType=VIP;Frequency=PERC;Perc=20.0"; diff --git a/Online/FarmConfig/options/HistSaver.opts b/Online/FarmConfig/options/HistSaver.opts deleted file mode 100755 index 013846dd15fc8f88fb13c21dd8e044971767b676..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/HistSaver.opts +++ /dev/null @@ -1,4 +0,0 @@ -// Job options file. Simple Online monitoring example -//============================================================== -#include "$AdderOptsFile" -MessageSvc.OutputLevel = 3; diff --git a/Online/FarmConfig/options/Hlt2MEPInit.opts b/Online/FarmConfig/options/Hlt2MEPInit.opts deleted file mode 100755 index f9195ed92cd650bc43e0a944493d32fadea00ffe..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/Hlt2MEPInit.opts +++ /dev/null @@ -1,4 +0,0 @@ -#include "$FARMCONFIGROOT/options/MEPInit.opts" - -// TODO: Add protection of buffers against missing consumers - diff --git a/Online/FarmConfig/options/Hlt2Main.opts b/Online/FarmConfig/options/Hlt2Main.opts deleted file mode 100755 index a7dc52a412f7aac8d8d8182315a994cbbd1fedfe..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/Hlt2Main.opts +++ /dev/null @@ -1,10 +0,0 @@ -#pragma print off -ApplicationMgr.ExtSvc = {"LHCb::GaudiTask::Configuration/Configuration" }; -ApplicationMgr.EventLoop = "LHCb::OnlineRunable/EmptyEventLoop"; -ApplicationMgr.Runable = "LHCb::OnlineRunable/Runable"; -ApplicationMgr.HistogramPersistency = "NONE"; -ApplicationMgr.EvtSel = "NONE"; -//MessageSvc.fifoPath = "$LOGFIFO"; -MessageSvc.OutputLevel = 4; -Runable.Wait = 1; -Main.DeclareStateOnPAUSE = true; diff --git a/Online/FarmConfig/options/Hlt2Writer.opts b/Online/FarmConfig/options/Hlt2Writer.opts deleted file mode 100755 index 354077159e3ce07071bfc6c787af3f4e37c2b928..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/Hlt2Writer.opts +++ /dev/null @@ -1,47 +0,0 @@ -// MSF: 04/12/2016: NEW Dataflow task type ! -#pragma print off -//------------- Default sender options: ------------------------------------------ -#include "$INFO_OPTIONS" -#include "$MBM_SETUP_OPTIONS" -#include "$FARMCONFIGROOT/options/Monitoring.opts" -Monitoring.CounterUpdateInterval = 3; -// -Manager.Services = {"Dataflow_MBMClient/MBM", - "Dataflow_FileWriter/HLT2", - "Dataflow_FileWriterMgr/WrManager", - "Dataflow_RunableWrapper/Wrap", - "Dataflow_UI/UI" - }; -// -Manager.Runable = "Wrap"; -Wrap.Callable = "WrManager"; -// -MBM.PartitionBuffers = @OnlineEnv.PartitionBuffers; -MBM.PartitionName = @OnlineEnv.PartitionName; -MBM.PartitionID = @OnlineEnv.PartitionID; -MBM.Buffers = @OnlineEnv.Hlt2Writer_Buffers; -// -Logger.OutputLevel = @OnlineEnv.OutputLevel; -// -WrManager.Input = @OnlineEnv.Hlt2Writer_Input; -WrManager.Processors = { "HLT2"}; -// -HLT2.SizeLimit = 3000; -HLT2.MaxFilesOpen = 190; -HLT2.FilePrefix = "${RUN1000}/${RUN}/Run_${RUN}_${NODE}_${TIME}.mdf"; -HLT2.MaxEvents = -1; -HLT2.DIMSteering = 0; -HLT2.DIMMonitoring = 0; -HLT2.PartitionName = @OnlineEnv.PartitionName; -HLT2.RunType = @OnlineEnv.RunType; -HLT2.Stream = "HLT2"; -HLT2.DeviceList = { "/daqarea1/objects/data/${PARTITION}/${STREAM}" }; -HLT2.DeviceList = { "/hlt2/data/${STREAM}/${PARTITION}" }; -HLT2.NodePattern = ""; -// -// Requirements for Physics -WrManager.Requirement = "EvType=2;TriggerMask=0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF;VetoMask=0,0,0,0;MaskType=ANY;UserType=VIP;Frequency=PERC;Perc=100.0"; -// -HLT2.Requirements = { - "EvType=2;TriggerMask=0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF;VetoMask=0,0,0,0;MaskType=ANY;UserType=VIP;Frequency=PERC;Perc=100.0" -}; diff --git a/Online/FarmConfig/options/L0Reader.opts b/Online/FarmConfig/options/L0Reader.opts deleted file mode 100755 index 89497d8a305e06eb16db587c57f4cb00acfae0e8..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/L0Reader.opts +++ /dev/null @@ -1,13 +0,0 @@ -#include "$FARMCONFIGROOT/options/BasicDiskReader.opts" -MEPManager.Buffers = @OnlineEnv.L0Reader_Buffers; -MEPManager.Buffers = @OnlineEnv.L0App_Buffers; -Runable.Rescan = false; -Runable.Directory = "/localdisk/Alignment/BWDivision"; -Runable.FilePrefix = "Run_"; -Runable.Buffer = @OnlineEnv.L0Reader_Output; -Runable.DeleteFiles = false; -Runable.InitialSleep = 0; -//Runable.GoService = "$GO_SERVICE_NAME"; -Runable.PauseSleep = 5; // Optional wait time until 'Output' event queue is empty -Runable.CheckedBuffers = @OnlineEnv.L0App_Buffers; -MessageSvc.OutputLevel = 3; diff --git a/Online/FarmConfig/options/L0Sender.opts b/Online/FarmConfig/options/L0Sender.opts deleted file mode 100755 index 2079e8a6478e88b61ab728946923c0d5a62a3fde..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/L0Sender.opts +++ /dev/null @@ -1,34 +0,0 @@ -#pragma print off -#include "$INFO_OPTIONS" -#include "$SUBFARM_OPTIONS" -#include "$MBM_SETUP_OPTIONS" -#include "$STATIC_OPTS/SvcMapping.opts" -#include "$STATIC_OPTS/Monitoring.opts" -ApplicationMgr.HistogramPersistency = "NONE"; -ApplicationMgr.ExtSvc += {"IncidentSvc", "MEPManager", "EventSelector"}; -ApplicationMgr.Runable = "Runable"; -// -Runable.MEPManager = "MEPManager"; -MonitorSvc.CounterUpdateInterval = 5; -// -MEPManager.PartitionBuffers = @OnlineEnv.PartitionBuffers; -MEPManager.PartitionID = @OnlineEnv.PartitionID; -MEPManager.PartitionName = @OnlineEnv.PartitionName; -MEPManager.Buffers = @OnlineEnv.L0Sender_Buffers; -// -//ApplicationMgr.TopAlg += {"Online::SocketDataSender/SND"}; -ApplicationMgr.TopAlg += {"Online::AsioDataSender/SND"}; -SND.DataSink = @OnlineEnv.Target; -SND.Compress = 0; -SND.DataType = 3; // MDF_NONE=1, MDF_RECORDS=2, MDF_BANKS=3 -SND.InputDataType = 3; - -EventDataSvc.RootCLID = 1; -EventDataSvc.EnableFaultHandler = true ; -EventPersistencySvc.CnvServices = { "RawDataCnvSvc" }; -EventSelector.MEPManager = "MEPManager"; -EventSelector.Input = @OnlineEnv.L0Sender_Input; -EventSelector.AllowSuspend = true; -EventSelector.Decode = false; -EventSelector.REQ1 = "EvType=2;TriggerMask=0xffffffff,0xffffffff,0xffffffff,0xffffffff;VetoMask=0,0,0,0;MaskType=ANY;UserType=VIP;Frequency=PERC;Perc=100.0"; -#include "$STATIC_OPTS/MessageSvc.opts" diff --git a/Online/FarmConfig/options/MEPInitCalib.opts b/Online/FarmConfig/options/MEPInitCalib.opts deleted file mode 100755 index f2ba29c9b5abbb929f03f7b82dfbaad9067162c2..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/MEPInitCalib.opts +++ /dev/null @@ -1,2 +0,0 @@ -#include "$FARMCONFIG_OPTIONS/MEPInit.opts" -MEPManager.InitFlags = "-s=200000 -e=500 -u=20 -b=17 -f -i=Events -c -s=40000 -e=150 -u=8 -b=17 -f -i=Overflow -c -s=30000 -e=150 -u=36 -f -i=Output -c"; diff --git a/Online/FarmConfig/options/MEPrx.opts b/Online/FarmConfig/options/MEPrx.opts deleted file mode 100755 index 03b8ca05ab28f5dd7a57c20b7f6fa189c4c2abb8..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/MEPrx.opts +++ /dev/null @@ -1,43 +0,0 @@ -#pragma print off -// -// MEPrx.opts -// Sample options for the eventbuilder service MEPRxSvc -// niko.neufeld@cern.ch -// -#include "$INFO_OPTIONS" -#include "$MBM_SETUP_OPTIONS" -#include "$TELL1BOARDS" -// -Manager.Services = {"Dataflow_MEPRx/Runable","Dataflow_RunableWrapper/EventProc", "Dataflow_UI/UI"}; -EventProc.Callable = "Runable"; -Manager.Runable = "EventProc"; -// -//Runable.OutputLevel = 1; -Runable.IncompleteEventPrint = 3; -Runable.MEPBuffers = 8; // concurrently built events -Runable.InitialMEPReqs = 8; // how many MEPs to send initially -Runable.maxMsForGetSpace = 100; // milliseconds to wait to get buffer memory from BM -Runable.partitionID = @OnlineEnv.PartitionID; -Runable.partitionName = @OnlineEnv.PartitionName; -Runable.partitionBuffers = @OnlineEnv.PartitionBuffers; -Runable.MEPBufSize = 4097152; // how much memory to allocate for an event 1 MB (large!!) -Runable.sockBuf = 30000000; // this must be supported by the kernel! -Runable.refCount = 2; -Runable.maxEventAge = 3000000; // (us) - put at least 10000, 0 to switch off -Runable.MEPRecvTimeout = 3000000; // (us) to wait in select call for new packet -Runable.alwaysSendMEPReq = true; // always send a MEPReq for any incomplete packet -Runable.createDAQErrorMEP = false; // do not create a summary bank about event-building errors -Runable.resetCountersOnRunChange = true; // reset all counters and histograms when a run-change is seen -// -Runable.nameLiveBuf = @OnlineEnv.MEPrx_Output; -Runable.nameOverflowBuf = ""; -Runable.overflow = 0; // Sleep delay (ms) for sending MEP requests. Used for rate control... -//Runable.ethInterface = 0; // interface number for data input eth"0" eth"1" etc... -Runable.RxIPAddr = "$IP_DATAINTERFACE"; -Runable.IPSrc = @OnlineEnv.Tell1Boards; -//Runable.RxIPAddr = "0.0.0.0"; -Runable.IPNameOdin = @OnlineEnv.ODIN_IP; -// -Monitoring.CounterUpdateInterval = 5; -Monitoring.DimUpdateInterval = 60; -Logger.OutputLevel = @OnlineEnv.OutputLevel; diff --git a/Online/FarmConfig/options/MEPrxCalib.opts b/Online/FarmConfig/options/MEPrxCalib.opts deleted file mode 100755 index bbbfc577761b57fda3a3f42b8df5b0142c33ce8f..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/MEPrxCalib.opts +++ /dev/null @@ -1,12 +0,0 @@ -#pragma print off -#include "$FARMCONFIG_OPTIONS/MEPrx.opts" -MEPManager.Buffers = {"Events"}; -Runable.nameLiveBuf = "Events"; -Runable.overflow = false; // do not use overflow -Runable.sockBuf = 67108864; -//disable MEP requests from Calib farm -//MessageSvc.OutputLevel = 1; -Runable.IPNameOdin = "192.168.254.194"; -Runable.MEPBuffers = 12; // concurrently built events -Runable.maxEventAge = 2000000; // (us) - put at least 10000, 0 to switch off -Runable.MEPRecvTimeout = 2000000; // (us) to wait in select call for new packet diff --git a/Online/FarmConfig/options/MEPrxNZS.opts b/Online/FarmConfig/options/MEPrxNZS.opts deleted file mode 100755 index 446e641a2ffcfbeed18a331a8d36c74974bd4ea5..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/MEPrxNZS.opts +++ /dev/null @@ -1,8 +0,0 @@ -#pragma print off -#include "$FARMCONFIGROOT/options/MEPrx.opts" -MEPManager.Buffers = @OnlineEnv.MEPrxNZS_Buffers; -Runable.nameLiveBuf = @OnlineEnv.MEPrxNZS_Output; - -Runable.MEPBuffers = 2; // concurrently built events -Runable.InitialMEPReqs = 3; // how many MEPs to send initially -Runable.MEPBufSize = 8194304; // how much memory to allocate for an event 1 MB (large!!) diff --git a/Online/FarmConfig/options/MFPGen.opts b/Online/FarmConfig/options/MFPGen.opts deleted file mode 100755 index 36469223fad9ce5821c004bc9c35d834cad04937..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/MFPGen.opts +++ /dev/null @@ -1,11 +0,0 @@ -#pragma print on -#include "$INFO_OPTIONS" -#include "/group/online/dataflow/options/${PARTITION}/EB/EB_transport.opts" -#include "$FARMCONFIG_OPTIONS/Logging.opts" - -Manager.Services = {"MFP_generator/MFP_generator", - "Dataflow_RunableWrapper/Wrap" - }; -Manager.Runable = "Wrap"; -Wrap.Callable = "MFP_generator"; -#include "/group/online/dataflow/options/${PARTITION}/EB/MFP_generator_params.opts" diff --git a/Online/FarmConfig/options/MessageSvc.opts b/Online/FarmConfig/options/MessageSvc.opts deleted file mode 100755 index 286fa05a1852a5a40e9819dcb6e531cf1ba1884f..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/MessageSvc.opts +++ /dev/null @@ -1,12 +0,0 @@ -// -// Message service setup -MessageSvc.fifoPath = "$LOGFIFO"; -MessageSvc.OutputLevel = @OnlineEnv.OutputLevel; -MonitorSvc.OutputLevel = @OnlineEnv.OutputLevel; -// -EventLoopMgr.OutputLevel = 5; -EventLoopMgr.Warnings = false; -// -// Disable histogram persistency -HistogramPersistencySvc.OutputLevel = 5; -HistogramPersistencySvc.Warnings = false; diff --git a/Online/FarmConfig/options/Moore1.opts b/Online/FarmConfig/options/Moore1.opts deleted file mode 100755 index 8ad876123e88ba4e86e3d77f6014a4c564076f48..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/Moore1.opts +++ /dev/null @@ -1,6 +0,0 @@ -#include "$STATIC_OPTS/Moore_Passthrough.opts" -MEPManager.Buffers = @OnlineEnv.Moore1_Buffers; -Merger.Buffer = @OnlineEnv.Moore1_Output; -EventSelector.Decode = true; // Reading MEP buffers from MBM. Decoding necessary -EventSelector.Input = @OnlineEnv.Moore1_Input; -EventSelector.REQ1 = "EvType=1;TriggerMask=0xffffffff,0xffffffff,0xffffffff,0xffffffff;VetoMask=0,0,0,0;MaskType=ANY;UserType=ONE;Frequency=PERC;Perc=100.0"; diff --git a/Online/FarmConfig/options/Moore2.opts b/Online/FarmConfig/options/Moore2.opts deleted file mode 100755 index ae17a3ac87e8d0697c28500ade812dc9f0beed1c..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/Moore2.opts +++ /dev/null @@ -1,6 +0,0 @@ -#include "$STATIC_OPTS/Moore_Passthrough.opts" -MEPManager.Buffers = @OnlineEnv.Moore2_Buffers; -Merger.Buffer = @OnlineEnv.Moore2_Output; -EventSelector.Decode = false; // Reading MDF banks from MBM. No decoding necessary -EventSelector.Input = @OnlineEnv.Moore2_Input; -EventSelector.REQ1 = "EvType=2;TriggerMask=0xffffffff,0xffffffff,0xffffffff,0xffffffff;VetoMask=0,0,0,0;MaskType=ANY;UserType=ONE;Frequency=PERC;Perc=100.0"; diff --git a/Online/FarmConfig/options/Moore_Passthrough.opts b/Online/FarmConfig/options/Moore_Passthrough.opts deleted file mode 100755 index f4eeae86c8c8fec65e6b6b6193c42a7e258c5418..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/Moore_Passthrough.opts +++ /dev/null @@ -1,53 +0,0 @@ -#include "$INFO_OPTIONS" -#include "$MBM_SETUP_OPTIONS" -#include "$STATIC_OPTS/SvcMapping.opts" -#include "$STATIC_OPTS/Monitoring.opts" - -ApplicationMgr.HistogramPersistency = "NONE"; -ApplicationMgr.Runable = "Runable"; -Runable.MEPManager = "MEPManager"; - -EventDataSvc.RootCLID = 1; -EventDataSvc.EnableFaultHandler = true; -EventPersistencySvc.CnvServices = { "RawDataCnvSvc" }; -MEPManager.ConnectWhen = "start"; -MEPManager.PartitionBuffers = true; -MEPManager.PartitionName = @OnlineEnv.PartitionName; -MEPManager.PartitionID = @OnlineEnv.PartitionID; -//MEPManager.Buffers = @OnlineEnv.Moore1_Buffers; -//EventSelector.Input = @OnlineEnv.Moore1_Input; - -HistogramPersistencySvc.Warnings = 0; - -ApplicationMgr.ExtSvc += { "LHCb::CheckpointSvc/CheckpointSvc" }; -// If the number of instances < 0: take the true number from the environment... -CheckpointSvc.NumberOfInstances = -1; -CheckpointSvc.Partition = @OnlineEnv.PartitionName; -CheckpointSvc.FirstChild = 0; -CheckpointSvc.ChildSleep = 50; -CheckpointSvc.TaskType = "$TASK_TYPE"; -//CheckpointSvc.UtgidPattern = "%P_%NN_%T_%02d"; -CheckpointSvc.UtgidPattern = "%UTGID%02d"; -CheckpointSvc.UseCores = false; -CheckpointSvc.ChildSessions = false; -CheckpointSvc.DumpFiles = false; -CheckpointSvc.PrintLevel = 3; -CheckpointSvc.OutputLevel = 2; - -// Prescale events declared to Send buffer -ApplicationMgr.TopAlg = { "Sequencer/SendSequence" }; -SendSequence.Members = { "LHCb::DelaySleepAlg/Delay", - "LHCb::RawEvent2MBMMergerAlg/Merger"}; -// Delay time in millisecs and in musecs -Delay.DelayTime = @OnlineEnv.passThroughDelay; -Delay.MicroDelayTime = 0; -//Merger.Buffer = @OnlineEnv.Moore1_Output; -Merger.Compress = 0; -Merger.DataType = 3; -Merger.InputDataType = 1; -// The banklocation is EXACTLY this. No /Event in front - otherwise TAE does not work! -Merger.BankLocation = "DAQ/RawEvent"; -Merger.RoutingBits = 1; -Merger.Silent = False; -Merger.TriggerMask = {0,4,0}; -#include "$STATIC_OPTS/MessageSvc.opts" diff --git a/Online/FarmConfig/options/NodeAdder.opts b/Online/FarmConfig/options/NodeAdder.opts deleted file mode 100755 index 727f904b31d1b525316df6fd16623bc9172f87ed..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/NodeAdder.opts +++ /dev/null @@ -1,71 +0,0 @@ -// Job options file. Simple Online monitoring example -//============================================================== -#include "$INFO_OPTIONS" - -ApplicationMgr.ExtSvc += {"MonitorSvc", - "AdderSvc/GauchoHistAdder", - "AdderSvc/GauchoCountAdder", - "AdderSvc/MEPrxHistAdder", - "AdderSvc/MEPrxCountAdder", - "AdderSvc/EVTProdCountAdder", - "AdderSvc/DiskWRCountAdder", - "AdderSvc/OverflowAdder", - "BusySvc" - }; -ApplicationMgr.EventLoop = "LHCb::OnlineRunable/EmptyEventLoop"; -ApplicationMgr.Runable = "LHCb::OnlineRunable/Runable"; -ApplicationMgr.HistogramPersistency = "NONE"; -ApplicationMgr.EvtSel = "NONE"; - -Runable.Wait = 3; // 1 of running as daemon (Class1 task) - -MessageSvc.fifoPath = "$LOGFIFO"; -MessageSvc.OutputLevel = @OnlineEnv.OutputLevel; -MonitorSvc.OutputLevel = @OnlineEnv.OutputLevel; -HistogramPersistencySvc.Warnings = false; - -GauchoHistAdder.MyName = "<node>_GauchoJob"; -GauchoHistAdder.TaskPattern = "<node>_GauchoJob_"; -GauchoHistAdder.ServicePattern = "MON_<node>_GauchoJob_(.*)/Histos/"; -GauchoHistAdder.AdderClass = "hists"; - -GauchoCountAdder.MyName = "<node>_GauchoJob"; -GauchoCountAdder.TaskPattern = "<node>_GauchoJob_"; -GauchoCountAdder.ServicePattern = "MON_<node>_GauchoJob_(.*)/Counter/"; -GauchoCountAdder.AdderClass = "Counter"; - -OverflowAdder.MyName = "<node>_OverflowWr"; -OverflowAdder.TaskPattern = "<node>_OverflowWr_"; -OverflowAdder.ServicePattern = "MON_<node>_OverflowWr_(.*)/Counter/"; -OverflowAdder.AdderClass = "Counter"; - -MEPrxHistAdder.MyName = "<node>_MEPrx"; -MEPrxHistAdder.ServicePattern = "MON_<node>_MEPrx_(.*)/Histos/"; -MEPrxHistAdder.TaskPattern = "<node>_MEPrx_"; -MEPrxHistAdder.AdderClass = "hists"; - -MEPrxCountAdder.MyName = "<node>_MEPrx"; -MEPrxCountAdder.ServicePattern = "MON_<node>_MEPrx_(.*)/Counter/"; -MEPrxCountAdder.TaskPattern = "<node>_MEPrx_"; -MEPrxCountAdder.AdderClass = "Counter"; - -EVTProdCountAdder.MyName = "<node>_EVTProd"; -EVTProdCountAdder.ServicePattern = "MON_<node>_EvtProd_(.*)/Counter/"; -EVTProdCountAdder.TaskPattern = "<node>_EVTProd_"; -EVTProdCountAdder.AdderClass = "Counter"; - -DiskWRCountAdder.MyName = "<node>_DiskWR"; -DiskWRCountAdder.ServicePattern = "MON_<node>_DiskWR_(.*)/Counter/"; -DiskWRCountAdder.TaskPattern = "<node>_DiskWR_"; -DiskWRCountAdder.AdderClass = "Counter"; - -MEPrxCountAdder.ReceiveTimeout = 2; -GauchoHistAdder.ReceiveTimeout = 3; -GauchoCountAdder.ReceiveTimeout = 3; -MEPrxHistAdder.ReceiveTimeout = 3; -EVTProdCountAdder.ReceiveTimeout = 3; -DiskWRCountAdder.ReceiveTimeout = 2; -OverflowAdder.ReceiveTimeout = 3; - -BusySvc.BogusMips = 0.0; -MonitorSvc.CounterUpdateInterval = 5; diff --git a/Online/FarmConfig/options/NodeAdderStatic.opts b/Online/FarmConfig/options/NodeAdderStatic.opts deleted file mode 100755 index 176fe3647450f829ab1589e77b127b485bc44db5..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/NodeAdderStatic.opts +++ /dev/null @@ -1,11 +0,0 @@ -// Adder Level 1===================== -//ApplicationMgr.ExtSvc += {"AdderSvc/Moore2CountAdder"}; - -//Moore2CountAdder.PartitionName = @OnlineEnv.PartitionName; -//Moore2CountAdder.MyName = "<part>_<node>_Moore2"; -//Moore2CountAdder.TaskPattern = "LHCb2_<node>_Moore2_(.*)"; -//Moore2CountAdder.ServicePattern = "MON_LHCb2_<node>_Moore2_(.*)/Counter/"; -//Moore2CountAdder.AdderClass = "Counter"; -//Moore2CountAdder.ReceiveTimeout = 7; - -//Runable.Wait = 1; diff --git a/Online/FarmConfig/options/NodeBsyMon.opts b/Online/FarmConfig/options/NodeBsyMon.opts deleted file mode 100755 index 28200720679686c167d822f4f02b100cd11a1559..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/NodeBsyMon.opts +++ /dev/null @@ -1,55 +0,0 @@ -ApplicationMgr.ExtSvc += {"MonitorSvc","BusySvc"}; -ApplicationMgr.ExtSvc += {"AdderSvc/Moore1CountAdder"}; -ApplicationMgr.ExtSvc += {"AdderSvc/PassThroughCountAdder"}; -ApplicationMgr.ExtSvc += {"AdderSvc/Moore2CountAdder"}; -ApplicationMgr.ExtSvc += {"AdderSvc/HLT2SenderAdder"}; - -ApplicationMgr.EventLoop = "LHCb::OnlineRunable/EmptyEventLoop"; -ApplicationMgr.Runable = "LHCb::OnlineRunable/Runable"; -ApplicationMgr.HistogramPersistency = "NONE"; -ApplicationMgr.EvtSel = "NONE"; - -Runable.Wait = 3; // 1 of running as daemon (Class1 task) - -MessageSvc.fifoPath = "$LOGFIFO"; -MessageSvc.OutputLevel = 3; -MonitorSvc.OutputLevel = 3; -HistogramPersistencySvc.Warnings = false; -BusySvc.BogusMips = 0.0; -MonitorSvc.CounterUpdateInterval = 5; -MonitorSvc.PartitionName = "GEN"; - -Moore1CountAdder.PartitionName = "LHCb"; -Moore1CountAdder.MyName = "GEN_<node>_Moore1"; -Moore1CountAdder.TaskPattern = "LHCb_<node>_Moore1_(.*)"; -Moore1CountAdder.ServicePattern = "MON_<part>_<node>_Moore1_(.*)/Counter/"; -//Moore1CountAdder.ServicePattern = "MON_<part>_<node>_(Moore1)|(PassThrough)/Counter/"; -Moore1CountAdder.AdderClass = "Counter"; -Moore1CountAdder.ReceiveTimeout = 7; -//Moore1CountAdder.DebugOn = true; -//Moore1CountAdder.Test = true; - -PassThroughCountAdder.PartitionName = "LHCb"; -PassThroughCountAdder.MyName = "GEN_<node>_PassThrough"; -PassThroughCountAdder.TaskPattern = "LHCb_<node>_PassThrough_(.*)"; -PassThroughCountAdder.ServicePattern = "MON_<part>_<node>_PassThrough_(.*)/Counter/"; -PassThroughCountAdder.AdderClass = "Counter"; -PassThroughCountAdder.ReceiveTimeout = 7; -//PassThroughCountAdder.DebugOn = true; -//PassThroughCountAdder.Test = true; - -Moore2CountAdder.PartitionName = "LHCb2"; -Moore2CountAdder.MyName = "GEN_<node>_Moore2"; -Moore2CountAdder.TaskPattern = "LHCb2_<node>_Moore2_(.*)"; -Moore2CountAdder.ServicePattern = "MON_<part>_<node>_Moore2_(.*)/Counter/"; -Moore2CountAdder.AdderClass = "Counter"; -Moore2CountAdder.ReceiveTimeout = 7; -Moore2CountAdder.Test = false; - -HLT2SenderAdder.PartitionName = "LHCb2"; -HLT2SenderAdder.MyName = "GEN_<node>_HLT2Sender"; -HLT2SenderAdder.TaskPattern = "LHCb2_<node>_Hlt2Sender_(.*)"; -HLT2SenderAdder.ServicePattern = "MON_<part>_<node>_Hlt2Sender_(.*)/Counter/"; -HLT2SenderAdder.AdderClass = "Counter"; -HLT2SenderAdder.ReceiveTimeout = 1; -#include "$AddTest" diff --git a/Online/FarmConfig/options/OdinCheck.opts b/Online/FarmConfig/options/OdinCheck.opts deleted file mode 100755 index 7f22d59d803cd12385a7c8834116d76ba6c1e07b..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/OdinCheck.opts +++ /dev/null @@ -1,27 +0,0 @@ -#include "$INFO_OPTIONS" -#include "$MBM_SETUP_OPTIONS" -#include "$STATIC_OPTS/SvcMapping.opts" -#include "$STATIC_OPTS/Monitoring.opts" - -ApplicationMgr.HistogramPersistency = "NONE"; -ApplicationMgr.Runable = "Runable"; -Runable.MEPManager = "MEPManager"; - -EventDataSvc.RootCLID = 1; -EventDataSvc.EnableFaultHandler = true; -EventPersistencySvc.CnvServices = { "RawDataCnvSvc" }; -MEPManager.ConnectWhen = "initialize"; -MEPManager.PartitionBuffers = true; -MEPManager.PartitionName = @OnlineEnv.PartitionName; -MEPManager.PartitionID = @OnlineEnv.PartitionID; - -HistogramPersistencySvc.Warnings = 0; -ApplicationMgr.TopAlg = { "LHCb::OdinCheckAlg/Check" }; -#include "$STATIC_OPTS/MessageSvc.opts" - -MEPManager.Buffers = {"Events"}; -EventSelector.Input = "Events"; -EventSelector.REQ1 = "EvType=1;TriggerMask=0xffffffff,0xffffffff,0xffffffff,0xffffffff;VetoMask=0,0,0,0;MaskType=ANY;UserType=VIP;Frequency=PERC;Perc=100.0"; -EventSelector.REQ2 = "EvType=2;TriggerMask=0xffffffff,0xffffffff,0xffffffff,0xffffffff;VetoMask=0,0,0,0;MaskType=ANY;UserType=VIP;Frequency=PERC;Perc=100.0"; -EventSelector.IntelligentSetup = true; -EventSelector.TAE = @OnlineEnv.TAE; diff --git a/Online/FarmConfig/options/OverflowReader.opts b/Online/FarmConfig/options/OverflowReader.opts deleted file mode 100755 index 8e4fe87b043d7dbcbbc4a338d79878235aa39d3d..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/OverflowReader.opts +++ /dev/null @@ -1,25 +0,0 @@ -#include "$INFO_OPTIONS" -#include "$MBM_SETUP_OPTIONS" -#include "$STATIC_OPTS/SvcMapping.opts" -#include "$STATIC_OPTS/Monitoring.opts" -// -ApplicationMgr.Runable = "LHCb::HltBufferedIOReader/Runable"; -ApplicationMgr.EventLoop = "LHCb::OnlineRunable/EventLoopMgr"; -ApplicationMgr.EvtSel = "NONE"; -ApplicationMgr.HistogramPersistency = "NONE"; -// -EventLoopMgr.Wait = 1; -// -Runable.Buffer = @OnlineEnv.MEPrx_Output; -Runable.DeleteFiles = true; -Runable.Directory = "/localdisk/overflow"; -Runable.AllowedRuns = @OnlineEnv.DeferredRuns; -Runable.BrokenHosts = "/group/online/dataflow/brokendisks"; -// -MEPManager.PartitionID = @OnlineEnv.PartitionID; -MEPManager.PartitionName = @OnlineEnv.PartitionName; -MEPManager.Buffers = @OnlineEnv.MEPrx_Buffers; -MEPManager.PartitionBuffers = @OnlineEnv.PartitionBuffers; -MEPManager.ConnectWhen = "initialize"; -// -#include "$STATIC_OPTS/MessageSvc.opts" diff --git a/Online/FarmConfig/options/OvrReader.opts b/Online/FarmConfig/options/OvrReader.opts deleted file mode 100755 index 2bcc98b9dd0e606f924f1297bccb81e46567a8b4..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/OvrReader.opts +++ /dev/null @@ -1,5 +0,0 @@ -#include "$FARMCONFIGROOT/options/BasicDiskReader.opts" -Runable.Directory = "/localdisk/overflow"; -Runable.FilePrefix = "Run_"; -Runable.Buffer = @OnlineEnv.OvrReader_Output; -MEPManager.Buffers = @OnlineEnv.OvrReader_Buffers; diff --git a/Online/FarmConfig/options/PTHiMu.opts b/Online/FarmConfig/options/PTHiMu.opts deleted file mode 100644 index 17743a4847e516022a0d6acf8da9eedc03440747..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/PTHiMu.opts +++ /dev/null @@ -1,13 +0,0 @@ -#include "$FARMCONFIGROOT/options/PassThroughBasic.opts" -MEPManager.Buffers = @OnlineEnv.PTHiMu_Buffers; -EventSelector.Input = @OnlineEnv.PTHiMu_Input; -Merger.Buffer = @OnlineEnv.PTHiMu_Output; -EventSelector.REQ1 = "EvType=1;TriggerMask=0xffffffff,0xffffffff,0xffffffff,0xffffffff;VetoMask=0,0,0,0;MaskType=ANY;UserType=ONE;Frequency=PERC;Perc=100.0"; -EventSelector.REQ2 = "EvType=2;TriggerMask=0xffffffff,0xffffffff,0xffffffff,0xffffffff;VetoMask=0,0,0,0;MaskType=ANY;UserType=ONE;Frequency=PERC;Perc=100.0"; -EventSelector.IntelligentSetup = true; -EventSelector.TAE = @OnlineEnv.TAE; -SendSequence.Members = { "LHCb::DelaySleepAlg/Delay", -// "LHCb::OdinPrescaler/Prescaler", - "LHCb::RawEvent2MBMMergerAlg/Merger"}; -Prescaler.DownscaleTriggerTypes = {}; - diff --git a/Online/FarmConfig/options/PassThrough.opts b/Online/FarmConfig/options/PassThrough.opts deleted file mode 100755 index 16390fd549eefbd141bafb03d9f6c78102a4d688..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/PassThrough.opts +++ /dev/null @@ -1,9 +0,0 @@ -#include "$FARMCONFIGROOT/options/PassThroughBasic.opts" -MEPManager.Buffers = @OnlineEnv.PassThrough_Buffers; -EventSelector.Input = @OnlineEnv.PassThrough_Input; -Merger.Buffer = @OnlineEnv.PassThrough_Output; -EventSelector.REQ1 = "EvType=1;TriggerMask=0xffffffff,0xffffffff,0xffffffff,0xffffffff;VetoMask=0,0,0,0;MaskType=ANY;UserType=ONE;Frequency=PERC;Perc=100.0"; -EventSelector.REQ2 = "EvType=2;TriggerMask=0xffffffff,0xffffffff,0xffffffff,0xffffffff;VetoMask=0,0,0,0;MaskType=ANY;UserType=ONE;Frequency=PERC;Perc=100.0"; -EventSelector.IntelligentSetup = true; -EventSelector.TAE = @OnlineEnv.TAE; - diff --git a/Online/FarmConfig/options/PassThroughBasic.opts b/Online/FarmConfig/options/PassThroughBasic.opts deleted file mode 100755 index e1a138f718a7fd91eac05ae51155c40f060b0b7e..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/PassThroughBasic.opts +++ /dev/null @@ -1,63 +0,0 @@ -#include "$INFO_OPTIONS" -#include "$MBM_SETUP_OPTIONS" -#include "$STATIC_OPTS/SvcMapping.opts" -#include "$STATIC_OPTS/Monitoring.opts" - -ApplicationMgr.HistogramPersistency = "NONE"; -ApplicationMgr.Runable = "Runable"; -Runable.MEPManager = "MEPManager"; - -EventDataSvc.RootCLID = 1; -EventDataSvc.EnableFaultHandler = true; -EventPersistencySvc.CnvServices = { "RawDataCnvSvc" }; -MEPManager.ConnectWhen = "start"; -MEPManager.PartitionBuffers = true; -MEPManager.PartitionName = @OnlineEnv.PartitionName; -MEPManager.PartitionID = @OnlineEnv.PartitionID; - -HistogramPersistencySvc.Warnings = 0; - -//ApplicationMgr.ExtSvc += { "Online::OnlineUISvc/UI" }; -//UI.When = "APP_RUNNING"; -ApplicationMgr.ExtSvc += { "LHCb::CheckpointSvc/CheckpointSvc" }; -// -#include "$CHECKPOINT_SETUP_OPTIONS" -CheckpointSvc.PrintLevel = 3; -CheckpointSvc.OutputLevel = 2; -// -EventSelector.REQ1 = "EvType=1;TriggerMask=0xffffffff,0xffffffff,0xffffffff,0xffffffff;VetoMask=0,0,0,0;MaskType=ANY;UserType=ONE;Frequency=PERC;Perc=100.0"; - -//ApplicationMgr.TopAlg = { "StoreExplorerAlg" }; -//StoreExplorerAlg.Load = 1; -//StoreExplorerAlg.PrintFreq = 0.0005; - -// Prescale events declared to Send buffer -ApplicationMgr.TopAlg = { "UpdateAndReset", "Sequencer/SendSequence" }; -SendSequence.Members = { "LHCb::DelaySleepAlg/Delay", - "LHCb::OdinPrescaler/Prescaler", - "LHCb::RawEvent2MBMMergerAlg/Merger"}; - -// Delay time in millisecs and in musecs -Delay.DelayTime = @OnlineEnv.passThroughDelay; -Delay.MicroDelayTime = 0; - -Prescaler.AcceptRate = @OnlineEnv.AcceptRate; -Prescaler.OutputLevel = @OnlineEnv.OutputLevel; - // Only apply downscaling to - // Random: 3 - // Periodic: 4 - // NZS: 5 -Prescaler.DownscaleTriggerTypes = {3,4,5}; - -Merger.Compress = 0; -Merger.DataType = 3; -Merger.InputDataType = 1; -// The banklocation is EXACTLY this. No /Event in front - otherwise TAE does not work! -Merger.BankLocation = "DAQ/RawEvent"; -Merger.RoutingBits = 0; -Merger.Silent = False; -// Set trigger mask of merged event to {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF} -//Merger.TriggerMask = {-1,-1,-1,1}; -Merger.TriggerMask = {0,4,0,1}; - -#include "$STATIC_OPTS/MessageSvc.opts" diff --git a/Online/FarmConfig/options/PassThroughMDF.opts b/Online/FarmConfig/options/PassThroughMDF.opts deleted file mode 100644 index 02e8e0fab7e55031f6db7d1f2fba32f3e3ed4151..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/PassThroughMDF.opts +++ /dev/null @@ -1,11 +0,0 @@ -#include "$FARMCONFIGROOT/options/PassThroughBasic.opts" -MEPManager.Buffers = @OnlineEnv.PassThroughMDF_Buffers; -EventSelector.Input = @OnlineEnv.PassThroughMDF_Input; -Merger.Buffer = @OnlineEnv.PassThroughMDF_Output; -EventSelector.REQ1 = "EvType=1;TriggerMask=0xffffffff,0xffffffff,0xffffffff,0xffffffff;VetoMask=0,0,0,0;MaskType=ANY;UserType=ONE;Frequency=PERC;Perc=100.0"; -EventSelector.REQ2 = "EvType=2;TriggerMask=0xffffffff,0xffffffff,0xffffffff,0xffffffff;VetoMask=0,0,0,0;MaskType=ANY;UserType=ONE;Frequency=PERC;Perc=100.0"; -EventSelector.IntelligentSetup = true; -EventSelector.TAE = false; -Prescaler.DownscaleTriggerTypes = {}; -Merger.TriggerMask = {-1,-1,-1,1}; - diff --git a/Online/FarmConfig/options/PassThrough_TAE.opts b/Online/FarmConfig/options/PassThrough_TAE.opts deleted file mode 100755 index 2545b4ed309c163d0c259e845cb6662aabf1869b..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/PassThrough_TAE.opts +++ /dev/null @@ -1,2 +0,0 @@ -#include "$STATIC_OPTS/PassThrough.opts" -EventSelector.Decode = false; diff --git a/Online/FarmConfig/options/ReaderMDF.opts b/Online/FarmConfig/options/ReaderMDF.opts deleted file mode 100755 index 1190388b047a5980b42ebcca91c99306544221d9..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/ReaderMDF.opts +++ /dev/null @@ -1,31 +0,0 @@ -// MSF: 04/12/2016: NEW Dataflow task type ! -#pragma print off -#include "$INFO_OPTIONS" -#include "$NODE_OPTIONS" -#include "$MBM_SETUP_OPTIONS" -#include "$FARMCONFIGROOT/options/Monitoring.opts" - -Manager.Services = {"Dataflow_MBMClient/MEPManager", - "Dataflow_HltReader/Reader", - "Dataflow_RunableWrapper/Wrap" - }; -Manager.Runable = "Wrap"; -Wrap.Callable = "Reader"; -Reader.Buffer = @OnlineEnv.ReaderMDF_Output; -Reader.BrokenHosts = ""; -Reader.Directories = {"/localdisk1/hlt1", "/localdisk2/hlt1"}; -Reader.AllowedRuns = @OnlineEnv.DeferredRuns; -Reader.DeleteFiles = true; -Reader.SaveRest = true; -Reader.FilePrefix = "Run_"; -Reader.PauseSleep = 5; // Optional wait time until 'Output' event queue is empty -Reader.InitialSleep = 1; -Reader.MaxPauseWait = 1; -Reader.GoService = "$GO_SERVICE_NAME"; -Reader.CheckedBuffers = @OnlineEnv.PassThroughMDF_Buffers; -// -MEPManager.PartitionBuffers = @OnlineEnv.PartitionBuffers; -MEPManager.PartitionName = @OnlineEnv.PartitionName; -MEPManager.PartitionID = @OnlineEnv.PartitionID; -MEPManager.Buffers = @OnlineEnv.ReaderMDF_Buffers; -Logger.OutputLevel = @OnlineEnv.OutputLevel; diff --git a/Online/FarmConfig/options/RouteTester.opts b/Online/FarmConfig/options/RouteTester.opts deleted file mode 100755 index 1907b7276b66335aac22808cdcef3a91f891d8f5..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/RouteTester.opts +++ /dev/null @@ -1,36 +0,0 @@ -#pragma print off -#include "$INFO_OPTIONS" -#include "$SUBFARM_OPTIONS" -#include "$MBM_SETUP_OPTIONS" -#include "$STATIC_OPTS/SvcMapping.opts" -//#include "$STATIC_OPTS/Monitoring.opts" - -ApplicationMgr.HistogramPersistency = "NONE"; -ApplicationMgr.ExtSvc += { "MonitorSvc" }; -ApplicationMgr.ExtSvc = {"IncidentSvc", "MEPManager", "EventSelector"}; -ApplicationMgr.Runable = "LHCb::EventRunable/Runable"; -ApplicationMgr.TopAlg += {"LHCb::RoutingBitsPrescaler/Prescaler"}; -MonitorSvc.UniqueServiceNames = 1; -MonitorSvc.ExpandCounterServices = 1; -MonitorSvc.ExpandNameInfix = "<proc>/"; -MonitorSvc.CounterUpdateInterval = 5; -Runable.MEPManager = "MEPManager"; -MEPManager.Buffers = @OnlineEnv.RouteTester_Buffers; -MEPManager.PartitionID = @OnlineEnv.PartitionID; -MEPManager.PartitionName = @OnlineEnv.PartitionName; -MEPManager.PartitionBuffers = @OnlineEnv.PartitionBuffers; -EventSelector.Input = @OnlineEnv.RouteTester_Input; -EventSelector.AllowSuspend = false; -EventSelector.Decode = false; -EventDataSvc.RootCLID = 1; -EventDataSvc.EnableFaultHandler = true ; -EventPersistencySvc.CnvServices = {"LHCb::RawDataCnvSvc/RawDataCnvSvc" }; -EventSelector.REQ1 = "$EVENTSELECTOR_REQ1"; -#include "$ONLINETASKS/options/MessageSvc.opts" -Prescaler.Requirements = { -"Name=All;EvType=2;TriggerMask=0xffffffff,0xffffffff,0xffffffff,0xffffffff;VetoMask=0,0,0,0;MaskType=ANY;UserType=VIP;Frequency=PERC;Perc=10.0", -"Name=Tracker;EvType=2;TriggerMask=0x0,0x00200000,0x0,0x0;VetoMask=0,0,0,0;MaskType=ANY;UserType=VIP;Frequency=PERC;Perc=100.0", -"Name=Rich;EvType=2;TriggerMask=0x0,0x00400000,0x0,0x0;VetoMask=0,0,0,0;MaskType=ANY;UserType=VIP;Frequency=PERC;Perc=100.0", -"Name=Velo;EvType=2;TriggerMask=0x0,0x00004008,0x0,0x0;VetoMask=0,0,0,0;MaskType=ANY;UserType=VIP;Frequency=PERC;Perc=100.0", -"Name=Muon;EvType=2;TriggerMask=0x0,0x00000400,0x0,0x0;VetoMask=0,0,0,0;MaskType=ANY;UserType=VIP;Frequency=PERC;Perc=100.0" -}; diff --git a/Online/FarmConfig/options/SFBsyAdder.opts b/Online/FarmConfig/options/SFBsyAdder.opts deleted file mode 100755 index 883044e4f335cb98392ddcdfd62a3e7dbba8e4a5..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/SFBsyAdder.opts +++ /dev/null @@ -1,67 +0,0 @@ -//ApplicationMgr.ExtSvc += {"MonitorSvc"}; -ApplicationMgr.EventLoop = "LHCb::OnlineRunable/EmptyEventLoop"; -ApplicationMgr.Runable = "LHCb::OnlineRunable/Runable"; -ApplicationMgr.HistogramPersistency = "NONE"; -ApplicationMgr.EvtSel = "NONE"; - -Runable.Wait = 3; // 1 of running as daemon (Class1 task) - -MessageSvc.fifoPath = "$LOGFIFO"; -//MessageSvc.OutputLevel = 3; -//MonitorSvc.OutputLevel = 3; -HistogramPersistencySvc.Warnings = false; -//MonitorSvc.CounterUpdateInterval = 5; -ApplicationMgr.ExtSvc += {"AdderSvc/BusyAdder"}; -ApplicationMgr.ExtSvc += {"AdderSvc/Moore1CountAdder"}; -ApplicationMgr.ExtSvc += {"AdderSvc/Moore2CountAdder"}; -ApplicationMgr.ExtSvc += {"AdderSvc/HLT2SenderAdder"}; -ApplicationMgr.ExtSvc += {"AdderSvc/PassThroughCountAdder"}; - -BusyAdder.MyName = "<part>_<node>_BusyMon"; -BusyAdder.PartitionName = "GEN"; -BusyAdder.TaskPattern = "<part>_<node>[0-9][0-9]_BusyMon"; -BusyAdder.ServicePattern = "MON_<part>_<node>[0-9][0-9]_BusyMon/Counter/"; -BusyAdder.AdderClass = "Counter"; -BusyAdder.ReceiveTimeout = 6; -BusyAdder.InDns = "<node>"; -BusyAdder.OutDns = "hlt01"; - -Moore1CountAdder.PartitionName = "GEN"; -Moore1CountAdder.MyName = "GEN_<node>_Moore1"; -Moore1CountAdder.TaskPattern = "<part>_<node>[0-9][0-9]_BusyMon"; -Moore1CountAdder.ServicePattern = "MON_<part>_<node>[0-9][0-9]_Moore1/Counter/"; -Moore1CountAdder.ReceiveTimeout = 10; -Moore1CountAdder.AdderClass = "Counter"; -Moore1CountAdder.InDNS = "<node>"; -Moore1CountAdder.OutDNS = "hlt01"; -//Moore1CountAdder.DebugOn = true; -//Moore1CountAdder.Test = true; - -Moore2CountAdder.PartitionName = "GEN"; -Moore2CountAdder.MyName = "GEN_<node>_Moore2"; -Moore2CountAdder.TaskPattern = "<part>_<node>[0-9][0-9]_BusyMon"; -Moore2CountAdder.ServicePattern = "MON_<part>_<node>[0-9][0-9]_Moore2/Counter/"; -Moore2CountAdder.ReceiveTimeout = 10; -Moore2CountAdder.AdderClass = "Counter"; -Moore2CountAdder.InDNS = "<node>"; -Moore2CountAdder.OutDNS = "hlt01"; -Moore2CountAdder.Test = false; - -PassThroughCountAdder.PartitionName = "GEN"; -PassThroughCountAdder.MyName = "GEN_<node>_PassThrough"; -PassThroughCountAdder.TaskPattern = "<part>_<node>[0-9][0-9]_BusyMon"; -PassThroughCountAdder.ServicePattern = "MON_<part>_<node>[0-9][0-9]_PassThrough/Counter/"; -PassThroughCountAdder.ReceiveTimeout = 10; -PassThroughCountAdder.AdderClass = "Counter"; -PassThroughCountAdder.InDNS = "<node>"; -PassThroughCountAdder.OutDNS = "hlt01"; - -HLT2SenderAdder.PartitionName = "GEN"; -HLT2SenderAdder.MyName = "GEN_<node>_HLT2Sender"; -HLT2SenderAdder.TaskPattern = "<part>_<node>[0-9][0-9]_BusyMon"; -HLT2SenderAdder.ServicePattern = "MON_<part>_<node>[0-9][0-9]_HLT2Sender/Counter/"; -HLT2SenderAdder.ReceiveTimeout = 4; -HLT2SenderAdder.AdderClass = "Counter"; -HLT2SenderAdder.InDNS = "<node>"; -HLT2SenderAdder.OutDNS = "hlt01"; -#include "$AddTest" diff --git a/Online/FarmConfig/options/StorageAdder.opts b/Online/FarmConfig/options/StorageAdder.opts deleted file mode 100755 index 404588b8d3af111ea02214f96a296f0524b0f125..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/StorageAdder.opts +++ /dev/null @@ -1,111 +0,0 @@ -#include "$INFO_OPTIONS" -//ApplicationMgr.ExtSvc += {"MonitorSvc","BusySvc"}; -ApplicationMgr.ExtSvc += {"AdderSvc/LumiCountAdder"}; -ApplicationMgr.ExtSvc += {"AdderSvc/WriterFull"}; -ApplicationMgr.ExtSvc += {"AdderSvc/WriterNoBias"}; -ApplicationMgr.ExtSvc += {"AdderSvc/WriterTurbo"}; -ApplicationMgr.ExtSvc += {"AdderSvc/WriterLowMult"}; -ApplicationMgr.ExtSvc += {"AdderSvc/WriterCalib"}; -ApplicationMgr.ExtSvc += {"AdderSvc/WriterBeamGas"}; -ApplicationMgr.ExtSvc += {"AdderSvc/WriterLumi"}; -ApplicationMgr.ExtSvc += {"AdderSvc/WriterSmogPhy"}; - -ApplicationMgr.EventLoop = "LHCb::OnlineRunable/EmptyEventLoop"; -ApplicationMgr.Runable = "LHCb::OnlineRunable/Runable"; -ApplicationMgr.HistogramPersistency = "NONE"; -ApplicationMgr.EvtSel = "NONE"; - -Runable.Wait = 3; // 1 of running as daemon (Class1 task) - -MessageSvc.fifoPath = "$LOGFIFO"; -MessageSvc.OutputLevel = 3; -//MonitorSvc.OutputLevel = 3; -//HistogramPersistencySvc.Warnings = false; -//BusySvc.BogusMips = 0.0; -//MonitorSvc.CounterUpdateInterval = 5; -//MonitorSvc.PartitionName = "GEN"; - -LumiCountAdder.PartitionName = @OnlineEnv.PartitionName; -LumiCountAdder.MyName = "<part>_StorageAdder_LumiCount"; -LumiCountAdder.TaskPattern = "<part>_STORERECV[[:digit:]]+[[:digit:]]+_WRTLumiCount_[0..9]"; -LumiCountAdder.ServicePattern = "MON_<part>_STORERECV[[:digit:]]+[[:digit:]]+_WRTLumiCount_[0..9]/Counter/"; -//LumiCountAdder.TaskPattern = "<part>_storerecv(.*)_WRTLumiCount(.*)"; -//LumiCountAdder.ServicePattern = "MON_<part>_storerecv(.*)_WRTLumiCount(.*)/Counter/"; -LumiCountAdder.AdderClass = "Counter"; -LumiCountAdder.ReceiveTimeout = 7; -LumiCountAdder.InDNS = "storectl01"; -LumiCountAdder.OutDNS = "mona08"; - -WriterFull.PartitionName = "LHCb2"; -WriterFull.MyName = "WriterFull"; -WriterFull.TaskPattern = "<part>_STORERECV[[:digit:]]+[[:digit:]]_WRTFull_[[:digit:]{1,2}]"; -WriterFull.ServicePattern = "MON_LHCb2_STORERECV[[:digit:]]+[[:digit:]]_WRTFull_[[:digit:]{1,2}]/Counter/"; -WriterFull.AdderClass="Counter"; -WriterFull.ReceiveTimeout = 7; -WriterFull.OutDNS = "ecs03"; -WriterFull.InDNS = "storectl01"; -WriterFull.ExpandRate = 1; - -WriterNoBias.PartitionName = "LHCb2"; -WriterNoBias.MyName = "WriterNoBias"; -WriterNoBias.TaskPattern = "<part>_STORERECV[[:digit:]]+[[:digit:]]_WRTNoBias_[[:digit:]{1,2}]"; -WriterNoBias.ServicePattern = "MON_LHCb2_STORERECV[[:digit:]]+[[:digit:]]_WRTNoBias_[[:digit:]{1,2}]/Counter/"; -WriterNoBias.AdderClass="Counter"; -WriterNoBias.ReceiveTimeout = 7; -WriterNoBias.OutDNS = "ecs03"; -WriterNoBias.InDNS = "storectl01"; - -WriterTurbo.PartitionName = "LHCb2"; -WriterTurbo.MyName = "WriterTurbo"; -WriterTurbo.TaskPattern = "<part>_STORERECV[[:digit:]]+[[:digit:]]_WRTTurbo_[[:digit:]{1,2}]"; -WriterTurbo.ServicePattern = "MON_LHCb2_STORERECV[[:digit:]]+[[:digit:]]_WRTTurbo_[[:digit:]{1,2}]/Counter/"; -WriterTurbo.AdderClass="Counter"; -WriterTurbo.ReceiveTimeout = 7; -WriterTurbo.OutDNS = "ecs03"; -WriterTurbo.InDNS = "storectl01"; - -WriterLowMult.PartitionName = "LHCb2"; -WriterLowMult.MyName = "WriterLowMult"; -WriterLowMult.TaskPattern = "<part>_STORERECV[[:digit:]]+[[:digit:]]_WRTLowMult_[[:digit:]{1,2}]"; -WriterLowMult.ServicePattern = "MON_LHCb2_STORERECV[[:digit:]]+[[:digit:]]_WRTLowMult_[[:digit:]{1,2}]/Counter/"; -WriterLowMult.AdderClass="Counter"; -WriterLowMult.ReceiveTimeout = 7; -WriterLowMult.OutDNS = "ecs03"; -WriterLowMult.InDNS = "storectl01"; - -WriterCalib.PartitionName = "LHCb2"; -WriterCalib.MyName = "WriterCalib"; -WriterCalib.TaskPattern = "<part>_STORERECV[[:digit:]]+[[:digit:]]_WRTCalib_[[:digit:]{1,2}]"; -WriterCalib.ServicePattern = "MON_LHCb2_STORERECV[[:digit:]]+[[:digit:]]_WRTCalib_[[:digit:]{1,2}]/Counter/"; -WriterCalib.AdderClass="Counter"; -WriterCalib.ReceiveTimeout = 7; -WriterCalib.OutDNS = "ecs03"; -WriterCalib.InDNS = "storectl01"; - -WriterBeamGas.PartitionName = "LHCb2"; -WriterBeamGas.MyName = "WriterBeamGas"; -WriterBeamGas.TaskPattern = "<part>_STORERECV[[:digit:]]+[[:digit:]]_WRTBeamGas_[[:digit:]{1,2}]"; -WriterBeamGas.ServicePattern = "MON_LHCb2_STORERECV[[:digit:]]+[[:digit:]]_WRTBeamGas_[[:digit:]{1,2}]/Counter/"; -WriterBeamGas.AdderClass="Counter"; -WriterBeamGas.ReceiveTimeout = 7; -WriterBeamGas.OutDNS = "ecs03"; -WriterBeamGas.InDNS = "storectl01"; - -WriterLumi.PartitionName = "LHCb2"; -WriterLumi.MyName = "WriterLumi"; -WriterLumi.TaskPattern = "<part>_STORERECV[[:digit:]]+[[:digit:]]_WRTLumi_[[:digit:]{1,2}]"; -WriterLumi.ServicePattern = "MON_LHCb2_STORERECV[[:digit:]]+[[:digit:]]_WRTLumi_[[:digit:]{1,2}]/Counter/"; -WriterLumi.AdderClass="Counter"; -WriterLumi.ReceiveTimeout = 7; -WriterLumi.OutDNS = "ecs03"; -WriterLumi.InDNS = "storectl01"; - -WriterSmogPhy.PartitionName = "LHCb2"; -WriterSmogPhy.MyName = "WriterSmogPhy"; -WriterSmogPhy.TaskPattern = "<part>_STORERECV[[:digit:]]+[[:digit:]]_WRTSmogPhy_[[:digit:]{1,2}]"; -WriterSmogPhy.ServicePattern = "MON_LHCb2_STORERECV[[:digit:]]+[[:digit:]]_WRTSmogPhy_[[:digit:]{1,2}]/Counter/"; -WriterSmogPhy.AdderClass="Counter"; -WriterSmogPhy.ReceiveTimeout = 7; -WriterSmogPhy.OutDNS = "ecs03"; -WriterSmogPhy.InDNS = "storectl01"; - diff --git a/Online/FarmConfig/options/StorageLumiCounter.opts b/Online/FarmConfig/options/StorageLumiCounter.opts deleted file mode 100755 index 50d72501ca1d1d7a83604a736ebecbd8a3e9a407..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/StorageLumiCounter.opts +++ /dev/null @@ -1,34 +0,0 @@ -// MSF: 04/12/2016: NEW Dataflow task type ! -#pragma print off -//------------- Default Writer options: ------------------------------------------ -//#include "$INFO_OPTIONS" -//#include "$MBM_SETUP_OPTIONS" -#include "../options/Monitoring.opts" -Manager.Services = {"Dataflow_MBMClient/MBM", - "Dataflow_LumiCounter/LumiCounter", - "Dataflow_FileWriterMgr/WrManager", - "Dataflow_RunableWrapper/Wrap" - }; -Manager.Runable = "Wrap"; -Wrap.Callable = "WrManager"; -// -MBM.PartitionBuffers = true; -MBM.PartitionName = @OnlineEnv.PartitionName; -MBM.PartitionID = @OnlineEnv.PartitionID; -MBM.Buffers = {"Events"}; -// -WrManager.Processors += {"LumiCounter"}; -WrManager.Input = "Events"; -// -LumiCounter.Requirements = { -//"EvType=2;TriggerMask=0x0,0x2,0x0,0x0;VetoMask=0,0,0,0;MaskType=ANY;UserType=VIP;Frequency=PERC;Perc=100.0" -"EvType=2;TriggerMask=0x0,0x0,0x40000000,0x0;VetoMask=0,0,0,0xb00;MaskType=ANY;UserType=VIP;Frequency=PERC;Perc=100.0" -}; -LumiCounter.DontCloseRuns = true; -LumiCounter.BackupFile = "LumiCounter1.file"; -LumiCounter.BackupDirectory = "/localdisk/CounterFiles/"; -LumiCounter.SynchPerEvent = false; -LumiCounter.SynchInterval = 5; -LumiCounter.MultiInstance = true; -Logger.OutputLevel = @OnlineEnv.OutputLevel; -Monitoring.CounterUpdateInterval = 5; diff --git a/Online/FarmConfig/options/StorageWriterAdder.opts b/Online/FarmConfig/options/StorageWriterAdder.opts deleted file mode 100755 index 21e6c375629e71ec409ca0519cb7e929b65685ed..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/StorageWriterAdder.opts +++ /dev/null @@ -1,97 +0,0 @@ -#include "/group/online/dataflow/options/LHCb2/LHCb2_RunInfo.opts" -//"Full", "NoBias", "Turbo", "LowMult", "Calib", "BeamGas", "Lumi", "SmogPhy", "Errors", "LumiCount" -ApplicationMgr.ExtSvc += {"AdderSvc/WriterFull"}; -ApplicationMgr.ExtSvc += {"AdderSvc/WriterNoBias"}; -ApplicationMgr.ExtSvc += {"AdderSvc/WriterTurbo"}; -ApplicationMgr.ExtSvc += {"AdderSvc/WriterLowMult"}; -ApplicationMgr.ExtSvc += {"AdderSvc/WriterCalib"}; -ApplicationMgr.ExtSvc += {"AdderSvc/WriterBeamGas"}; -ApplicationMgr.ExtSvc += {"AdderSvc/WriterLumi"}; -ApplicationMgr.ExtSvc += {"AdderSvc/WriterSmogPhy"}; - -ApplicationMgr.EventLoop = "LHCb::OnlineRunable/EmptyEventLoop"; -ApplicationMgr.Runable = "LHCb::OnlineRunable/Runable"; -ApplicationMgr.HistogramPersistency = "NONE"; -ApplicationMgr.EvtSel = "NONE"; - -Runable.Wait = 3; // 1 of running as daemon (Class1 task) - -MessageSvc.fifoPath = "$LOGFIFO"; -MessageSvc.OutputLevel = 3; -MonitorSvc.OutputLevel = 3; -HistogramPersistencySvc.Warnings = false; - -WriterFull.PartitionName = "LHCb2"; -WriterFull.MyName = "WriterFull"; -WriterFull.TaskPattern = "<part>_STORERECV[0..9][0..9]_WRTFull_(.*)"; -WriterFull.ServicePattern = "MON_<part>_STORERECV[0..9][0..9]_WRTFull_(.*)/Counter/"; -WriterFull.AdderClass="Counter"; -WriterFull.ReceiveTimeout = 2; -WriterFull.OutDNS = "ecs03"; -WriterFull.InDNS = "storectl01"; - -WriterNoBias.PartitionName = "LHCb2"; -WriterNoBias.MyName = "WriterNoBias"; -WriterNoBias.TaskPattern = "<part>_STORERECV[0..9][0..9]_WRTNoBias_(.*)"; -WriterNoBias.ServicePattern = "MON_<part>_STORERECV[0..9][0..9]_WRTNoBias_(.*)/Counter/"; -WriterNoBias.AdderClass="Counter"; -WriterNoBias.ReceiveTimeout = 2; -WriterNoBias.OutDNS = "ecs03"; -WriterNoBias.InDNS = "storectl01"; - - -WriterTurbo.PartitionName = "LHCb2"; -WriterTurbo.MyName = "WriterTurbo"; -WriterTurbo.TaskPattern = "<part>_STORERECV[0..9][0..9]_WRTTurbo_(.*)"; -WriterTurbo.ServicePattern = "MON_<part>_STORERECV[0..9][0..9]_WRTTurbo_(.*)/Counter/"; -WriterTurbo.AdderClass="Counter"; -WriterTurbo.ReceiveTimeout = 2; -WriterTurbo.OutDNS = "ecs03"; -WriterTurbo.InDNS = "storectl01"; - -WriterLowMult.PartitionName = "LHCb2"; -WriterLowMult.MyName = "WriterLowMult"; -WriterLowMult.TaskPattern = "<part>_STORERECV[0..9][0..9]_WRTLowMult_(.*)"; -WriterLowMult.ServicePattern = "MON_<part>_STORERECV[0..9][0..9]_WRTLowMult_(.*)/Counter/"; -WriterLowMult.AdderClass="Counter"; -WriterLowMult.ReceiveTimeout = 2; -WriterLowMult.OutDNS = "ecs03"; -WriterLowMult.InDNS = "storectl01"; - -WriterCalib.PartitionName = "LHCb2"; -WriterCalib.MyName = "WriterCalib"; -WriterCalib.TaskPattern = "<part>_STORERECV[0..9][0..9]_WRTCalib_(.*)"; -WriterCalib.ServicePattern = "MON_<part>_STORERECV[0..9][0..9]_WRTCalib_(.*)/Counter/"; -WriterCalib.AdderClass="Counter"; -WriterCalib.ReceiveTimeout = 2; -WriterCalib.OutDNS = "ecs03"; -WriterCalib.InDNS = "storectl01"; - -WriterBeamGas.PartitionName = "LHCb2"; -WriterBeamGas.MyName = "WriterBeamGas"; -WriterBeamGas.TaskPattern = "<part>_STORERECV[0..9][0..9]_WRTBeamGas_(.*)"; -WriterBeamGas.ServicePattern = "MON_<part>_STORERECV[0..9][0..9]_WRTBeamGas_(.*)/Counter/"; -WriterBeamGas.AdderClass="Counter"; -WriterBeamGas.ReceiveTimeout = 2; -WriterBeamGas.OutDNS = "ecs03"; -WriterBeamGas.InDNS = "storectl01"; - -WriterLumi.PartitionName = "LHCb2"; -WriterLumi.MyName = "WriterLumi"; -WriterLumi.TaskPattern = "<part>_STORERECV[0..9][0..9]_WRTLumi_(.*)"; -WriterLumi.ServicePattern = "MON_<part>_STORERECV[0..9][0..9]_WRTLumi_(.*)/Counter/"; -WriterLumi.AdderClass="Counter"; -WriterLumi.ReceiveTimeout = 2; -WriterLumi.OutDNS = "ecs03"; -WriterLumi.InDNS = "storectl01"; - -WriterSmogPhy.PartitionName = "LHCb2"; -WriterSmogPhy.MyName = "WriterSmogPhy"; -WriterSmogPhy.TaskPattern = "<part>_STORERECV[0..9][0..9]_WRTSmogPhy_(.*)"; -WriterSmogPhy.ServicePattern = "MON_<part>_STORERECV[0..9][0..9]_WRTSmogPhy_(.*)/Counter/"; -WriterSmogPhy.AdderClass="Counter"; -WriterSmogPhy.ReceiveTimeout = 2; -WriterSmogPhy.OutDNS = "ecs03"; -WriterSmogPhy.InDNS = "storectl01"; - -//#include "$AddTest" diff --git a/Online/FarmConfig/options/StorageWriterBasic.opts b/Online/FarmConfig/options/StorageWriterBasic.opts deleted file mode 100644 index af9e00801eb0e6edd7cdf5346b23f5312b609840..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/StorageWriterBasic.opts +++ /dev/null @@ -1,44 +0,0 @@ -#pragma print on -//#include "$INFO_OPTIONS" -#include "$FARMCONFIGROOT/options/Monitoring.opts" -#include "$FARMCONFIGROOT/options/OnlineStreams.opts" -Manager.Services = {"Dataflow_DiskWriter/EventSelector", - "Dataflow_RunableWrapper/Wrap" - }; -Task.HavePause = true; -Manager.Runable = "Wrap"; -Wrap.Callable = "EventSelector"; -EventSelector.NumWorkers = 5; -EventSelector.EventsHigh = 5000; -EventSelector.PartitionID = @OnlineEnv.PartitionID; -EventSelector.PartitionName = @OnlineEnv.PartitionName; -EventSelector.PartitionBuffers = true; -EventSelector.DefaultCloseTimeout_sec = 30; -EventSelector.DefaultFileSize_Mbyte = 150; -EventSelector.DefaultBufferDepth = 0; -EventSelector.DefaultBufferSize_kbyte = 2000; -EventSelector.DeleteOutput = false; -EventSelector.CloseCheckTime_ms = 5000; -EventSelector.UnusedCheckTime_ms = 5000; -EventSelector.DebugInputs = true; -EventSelector.DebugOutputs = true; -EventSelector.DebugFileHandling = true; -EventSelector.DebugLoop = false; - -EventSelector.RundbDebug = 0; - -// We do not need masks here: They will be computed from the streams -EventSelector.Requirement = "EvType=2;MaskType=ANY;UserType=CALIB;Frequency=PERC;Perc=100.0"; -EventSelector.InputSpecifications = { - "mbm": { "buffer": "Events", "debug": "0", "multiplicity": "4" } -}; - -EventSelector.WriterdDebugAcks = 0; -EventSelector.WriterdDebugSend = 0; -EventSelector.WriterdDebugOpen = 0; -EventSelector.WriterdDebugClose = 0; -EventSelector.WriterdDebugFailover = 2; -EventSelector.WriterdLostAck_percent = -1.0; -EventSelector.WriterdSendFail_percent = -1.0; -Logger.OutputLevel = 1; -Logger.LockedOutput = true; diff --git a/Online/FarmConfig/options/SubFarmAdder.opts b/Online/FarmConfig/options/SubFarmAdder.opts deleted file mode 100755 index 9147b42c29addaa4e247418cde6bc4f4697e7938..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/SubFarmAdder.opts +++ /dev/null @@ -1,100 +0,0 @@ -// Job options file. Simple Online monitoring example -//============================================================== -#include "$INFO_OPTIONS" - -ApplicationMgr.ExtSvc += {"MonitorSvc", - "AdderSvc", - "AdderSvc/GauchoHistAdder", - "AdderSvc/GauchoCountAdder", - "AdderSvc/OverflowAdder", - "AdderSvc/MEPrxHistAdder", - "AdderSvc/MEPrxCountAdder", - "AdderSvc/EVTProdCountAdder", - "AdderSvc/DiskWRCountAdder", - "AdderSvc/BusyAdder" - }; -// ApplicationMgr.ExtSvc += {"MemTrnd" }; - -ApplicationMgr.EventLoop = "LHCb::OnlineRunable/EmptyEventLoop"; -ApplicationMgr.Runable = "LHCb::OnlineRunable/Runable"; -ApplicationMgr.HistogramPersistency = "NONE"; -ApplicationMgr.EvtSel = "NONE"; -Runable.Wait = 3; // 1 of running as daemon - -MessageSvc.fifoPath = "$LOGFIFO"; -MessageSvc.OutputLevel = @OnlineEnv.OutputLevel; -HistogramPersistencySvc.Warnings = false; - -MemTrnd.PartitionName = @OnlineEnv.PartitionName; -MemTrnd.TrendInterval = 30; - -AdderSvc.MyName = "<part>_<node>_Adder"; -AdderSvc.PartitionName = @OnlineEnv.PartitionName; -AdderSvc.TaskPattern = "<node>[0-9][0-9]_Adder_01"; -AdderSvc.ServicePattern = "MON_<node>[0-9][0-9]_Adder_01/Histos/"; -AdderSvc.AdderClass = "hists"; -AdderSvc.InDNS = "<node>"; - -GauchoHistAdder.MyName = "<part>_<node>_GauchoJob"; -GauchoHistAdder.PartitionName = @OnlineEnv.PartitionName; -GauchoHistAdder.TaskPattern = "<node>[0-9][0-9]_Adder"; -GauchoHistAdder.ServicePattern = "MON_<node>[0-9][0-9]_GauchoJob/Histos/"; -GauchoHistAdder.AdderClass = "hists"; -GauchoHistAdder.InDNS = "<node>"; - -GauchoCountAdder.MyName = "<part>_<node>_GauchoJob"; -GauchoCountAdder.PartitionName = @OnlineEnv.PartitionName; -GauchoCountAdder.TaskPattern = "<node>[0-9][0-9]_Adder"; -GauchoCountAdder.ServicePattern = "MON_<node>[0-9][0-9]_GauchoJob/Counter/"; -GauchoCountAdder.AdderClass = "Counter"; -GauchoCountAdder.InDNS = "<node>"; - -OverflowAdder.MyName = "<part>_<node>_OverflowWr"; -OverflowAdder.PartitionName = @OnlineEnv.PartitionName; -OverflowAdder.TaskPattern = "<node>[0-9][0-9]_Adder"; -OverflowAdder.ServicePattern = "MON_<node>[0-9][0-9]_OverflowWr/Counter/"; -OverflowAdder.AdderClass = "Counter"; -OverflowAdder.InDNS = "<node>"; - -MEPrxHistAdder.MyName = "<part>_<node>_MEPrx"; -MEPrxHistAdder.PartitionName = @OnlineEnv.PartitionName; -MEPrxHistAdder.TaskPattern = "<node>[0-9][0-9]_Adder"; -MEPrxHistAdder.ServicePattern = "MON_<node>[0-9][0-9]_MEPrx/Histos/"; -MEPrxHistAdder.AdderClass = "hists"; -MEPrxHistAdder.InDNS = "<node>"; - -MEPrxCountAdder.MyName = "<part>_<node>_MEPrx"; -MEPrxCountAdder.PartitionName = @OnlineEnv.PartitionName; -MEPrxCountAdder.TaskPattern = "<node>[0-9][0-9]_Adder"; -MEPrxCountAdder.ServicePattern = "MON_<node>[0-9][0-9]_MEPrx/Counter/"; -MEPrxCountAdder.AdderClass = "Counter"; -MEPrxCountAdder.InDNS = "<node>"; - -EVTProdCountAdder.MyName = "<part>_<node>_EVTProd"; -EVTProdCountAdder.PartitionName = @OnlineEnv.PartitionName; -EVTProdCountAdder.TaskPattern = "<node>[0-9][0-9]_Adder"; -EVTProdCountAdder.ServicePattern = "MON_<node>[0-9][0-9]_EVTProd/Counter/"; -EVTProdCountAdder.AdderClass = "Counter"; -EVTProdCountAdder.InDNS = "<node>"; - -DiskWRCountAdder.MyName = "<part>_<node>_DiskWR"; -DiskWRCountAdder.PartitionName = @OnlineEnv.PartitionName; -DiskWRCountAdder.TaskPattern = "<node>[0-9][0-9]_Adder"; -DiskWRCountAdder.ServicePattern = "MON_<node>[0-9][0-9]_DiskWR/Counter/"; -DiskWRCountAdder.AdderClass = "Counter"; -DiskWRCountAdder.InDNS = "<node>"; - -BusyAdder.MyName = "<part>_<node>_Busy"; -BusyAdder.PartitionName = @OnlineEnv.PartitionName; -BusyAdder.TaskPattern = "<node>[0-9][0-9]_Adder"; -BusyAdder.ServicePattern = "MON_<node>[0-9][0-9]_Adder_01/Counter/"; -BusyAdder.AdderClass = "Counter"; -BusyAdder.InDNS = "<node>"; - -MEPrxCountAdder.ReceiveTimeout = 3; -GauchoHistAdder.ReceiveTimeout = 6; -GauchoCountAdder.ReceiveTimeout = 6; -MEPrxHistAdder.ReceiveTimeout = 6; -EVTProdHistAdder.ReceiveTimeout = 6; -DiskWRHistAdder.ReceiveTimeout = 3; -BusyAdder.ReceiveTimeout = 3; diff --git a/Online/FarmConfig/options/SubFarmAdderStatic.opts b/Online/FarmConfig/options/SubFarmAdderStatic.opts deleted file mode 100755 index f2ae3322f2a5a5cc4eb0240544a929aa2739ab38..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/SubFarmAdderStatic.opts +++ /dev/null @@ -1,12 +0,0 @@ -ApplicationMgr.ExtSvc += {"AdderSvc/Moore2CountAdder"}; - - -Moore2CountAdder.PartitionName = @OnlineEnv.PartitionName; -Moore2CountAdder.MyName = "<part>_<node>_Moore2"; -Moore2CountAdder.TaskPattern = "<part>_<node>[0-9][0-9]_NodeAdder_0"; -Moore2CountAdder.ServicePattern = "MON_<part>_<node>[0-9][0-9]_Moore2/Counter/"; -Moore2CountAdder.ReceiveTimeout = 10; -Moore2CountAdder.AdderClass = "Counter"; -Moore2CountAdder.InDNS = "<node>"; -Moore2CountAdder.OutDNS = "hlt01"; - diff --git a/Online/FarmConfig/options/SvcMapping.opts b/Online/FarmConfig/options/SvcMapping.opts deleted file mode 100755 index 77446fc86c7d641f8458d5792543f95b94a993ca..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/SvcMapping.opts +++ /dev/null @@ -1,7 +0,0 @@ -ApplicationMgr.SvcOptMapping += {"Online::EventRunable/Runable", - "Online::OnlineEvtSelector/EventSelector", - "LHCb::RawDataCnvSvc/RawDataCnvSvc", - "Online::MEPManager/MEPManager", - "Gaudi::MultiFileCatalog/FileCatalog", - "Gaudi::IODataManager/IODataManager" -}; diff --git a/Online/FarmConfig/options/TrgMaskCheck.opts b/Online/FarmConfig/options/TrgMaskCheck.opts deleted file mode 100644 index 31bd278fd3568fe8ab0177a4960c51751526ab67..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/TrgMaskCheck.opts +++ /dev/null @@ -1,7 +0,0 @@ -#include "$ONLINETASKS/options/MON.opts" -// -// Herschel trigger mask: -EventSelector.REQ1 = "EvType=2;TriggerMask=0x0,0x2010000,0x0,0x1;VetoMask=0,0,0,0x0;MaskType=ANY;UserType=USER;Frequency=PERC;Perc=100.0"; -ApplicationMgr.TopAlg = { "UpdateAndReset","Online::TriggerMaskCheckAlg/TrgMaskCheck" }; -TrgMaskCheck.Requirement = @EventSelector.REQ1; -//EventSelector.REQ1 = "EvType=2;TriggerMask=0x0,0x0,0x0,0x0;VetoMask=0,0,0,0xFFFFFFFF;MaskType=ANY;UserType=USER;Frequency=PERC;Perc=100.0"; diff --git a/Online/FarmConfig/options/TrgMaskCheck_TAE.opts b/Online/FarmConfig/options/TrgMaskCheck_TAE.opts deleted file mode 100644 index 3076c1c56d90adf5d40e4c14bc44ef42e4315552..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/TrgMaskCheck_TAE.opts +++ /dev/null @@ -1,3 +0,0 @@ -#include "$FarmConfigROOT/TrgMaskCheck.opts" -// We do not want to see anything -EventSelector.REQ1 = "EvType=2;TriggerMask=0x0,0x0,0x0,0x0;VetoMask=0,0,0,0xFFFFFFFF;MaskType=ANY;UserType=USER;Frequency=PERC;Perc=100.0"; diff --git a/Online/FarmConfig/options/VeloCalibMerge.opts b/Online/FarmConfig/options/VeloCalibMerge.opts deleted file mode 100755 index bb21ae69bb8422f6caff9937fd5cf7ee02921631..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/VeloCalibMerge.opts +++ /dev/null @@ -1,30 +0,0 @@ -#pragma print off -// -// Velo event selection process running on the CALIBRATION farm -// -#include "$INFO_OPTIONS" -#include "$FARMCONFIGROOT/options/Monitoring.opts" - -Manager.Services = {"Dataflow_MBMClient/MBM", - "Dataflow_MEPSelector/EventSelector", - "Dataflow_CalibAndTriggerTypeFilter/Filter", - "Dataflow_MBMWriter/Writer", - "Dataflow_UI/UI" - }; -Manager.Algorithms = {"Dataflow_ComponentContainer/Sequencer"}; -Manager.Runable = "EventSelector"; - -MBM.Buffers = {"Events", "Output"}; -MBM.PartitionID = @OnlineEnv.PartitionID; -MBM.PartitionName = @OnlineEnv.PartitionName; -MBM.PartitionBuffers = true; -EventSelector.Input = "Events"; -EventSelector.REQ1 = "EvType=1;TriggerMask=0xffffffff,0xffffffff,0xffffffff,0xffffffff;VetoMask=0,0,0,0;MaskType=ANY;UserType=USER;Frequency=PERC;Perc=100.0"; -Writer.Buffer = "Output"; - -Sequencer.Components = {"Filter", "Writer"}; -Sequencer.Mode_AND = true; -Filter.TriggerTypesToPass = {4, 7}; -Filter.CalibTypesToPass = {2, 3}; - -Logger.OutputLevel = @OnlineEnv.OutputLevel; diff --git a/Online/FarmConfig/options/VeloCalibMerge_Gaudi.opts b/Online/FarmConfig/options/VeloCalibMerge_Gaudi.opts deleted file mode 100644 index b644b256d5687a9b3d6064529db32b477da34a38..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/VeloCalibMerge_Gaudi.opts +++ /dev/null @@ -1,41 +0,0 @@ -// -// Velo event selection process running on the CALIBRATION farm -// -#include "$INFO_OPTIONS" -#include "$ONLINETASKS/options/SvcMapping.opts" -#include "$ONLINETASKS/options/Monitoring.opts" -ApplicationMgr.HistogramPersistency = "NONE"; -ApplicationMgr.ExtSvc += {"IncidentSvc"}; -ApplicationMgr.ExtSvc += { "LHCb::OnlineEvtSelector/EventSelector"}; -ApplicationMgr.ExtSvc += { "LHCb::MEPManager/MEPManager"}; -ApplicationMgr.Runable = "LHCb::EventRunable/Runable"; -Runable.MEPManager = "LHCb::MEPManager/MEPManager"; -MEPManager.Buffers = {"EVENT","SEND"}; -MEPManager.PartitionID = @OnlineEnv.PartitionID; -MEPManager.PartitionName = @OnlineEnv.PartitionName; -MEPManager.PartitionBuffers = true; -// -EventSelector.AllowSuspend = false; -MEPManager.Buffers = {"Events", "Output"}; -EventSelector.Input = "Events"; -EventSelector.REQ1 = "EvType=1;TriggerMask=0xffffffff,0xffffffff,0xffffffff,0xffffffff;VetoMask=0,0,0,0;MaskType=ANY;UserType=USER;Frequency=PERC;Perc=100.0"; -// -EventDataSvc.RootCLID = 1; -EventDataSvc.EnableFaultHandler = true; -EventPersistencySvc.CnvServices = {"LHCb::RawDataCnvSvc/RawDataCnvSvc" }; -ApplicationMgr.TopAlg = {"Sequencer/Sequencer"}; -//Sequencer.Members = {"LHCb::TriggerTypeFilter/Filter", "LHCb::RawEvent2MBMMergerAlg/Merger"}; -//Filter.TriggerTypeToPass = 4; -// -Sequencer.Members = {"LHCb::CalibAndTriggerTypeFilter/Filter", "LHCb::RawEvent2MBMMergerAlg/Merger"}; -Filter.TriggerTypesToPass = { 4, 7}; -Filter.CalibTypesToPass = { 2, 3}; -// -Merger.Buffer = "Output"; -Merger.Compress = 0; -//Merger.DataType = 3; // MDF_NONE = 1 MDF_RECORDS = 2 MDF_BANKS = 3 -Merger.InputDataType = 1; -Merger.BankLocation = "/Event/DAQ/RawEvent"; -Merger.RoutingBits = 2048; // = 0x800 -#include "$ONLINETASKS/options/EventLoopMgr.opts" -#include "$ONLINETASKS/options/MessageSvc.opts" diff --git a/Online/FarmConfig/options/VeloCalibWrite.opts b/Online/FarmConfig/options/VeloCalibWrite.opts deleted file mode 100644 index 7165f61b255ad008f8d5a0f5f456ccd72b8b8847..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/VeloCalibWrite.opts +++ /dev/null @@ -1,54 +0,0 @@ -#pragma print on -#include "$INFO_OPTIONS" -#include "$FARMCONFIGROOT/options/Monitoring.opts" -#include "$FARMCONFIGROOT/options/OnlineStreams.opts" -Manager.Services = {"Dataflow_DiskWriter/EventSelector", - "Dataflow_RunableWrapper/Wrap", - "Dataflow_UI/UI" - }; -Task.HavePause = true; -Manager.Runable = "Wrap"; -Wrap.Callable = "EventSelector"; -EventSelector.NumWorkers = 5; -EventSelector.EventsHigh = 5000; -EventSelector.PartitionID = @OnlineEnv.PartitionID; -EventSelector.PartitionName = @OnlineEnv.PartitionName; -EventSelector.PartitionBuffers = true; -EventSelector.DefaultCloseTimeout_sec = 30; -EventSelector.DefaultFileSize_Mbyte = 150; -EventSelector.DefaultBufferDepth = 0; -EventSelector.DefaultBufferSize_kbyte = 2000; -EventSelector.DeleteOutput = false; -EventSelector.CloseCheckTime_ms = 5000; -EventSelector.UnusedCheckTime_ms = 5000; -EventSelector.DebugInputs = true; -EventSelector.DebugOutputs = true; -EventSelector.DebugFileHandling = true; -EventSelector.DebugLoop = false; - -EventSelector.RundbDebug = 0; -EventSelector.RundbConnection = "http://pluscc06.lbdaq.cern.ch:8050"; - -// We do not need masks here: They will be computed from the streams -EventSelector.Requirement = "EvType=2;MaskType=ANY;UserType=CALIB;Frequency=PERC;Perc=100.0"; -EventSelector.InputSpecifications = { - "mbm": { "buffer": "Output", "debug": "0", "multiplicity": "2" } -}; - -EventSelector.Output = { - "OnlineStreams": ["Calib"] -}; - -EventSelector.WriterdDebugAcks = 0; -EventSelector.WriterdDebugSend = 0; -EventSelector.WriterdDebugOpen = 0; -EventSelector.WriterdDebugClose = 0; -EventSelector.WriterdDebugFailover = 2; -EventSelector.WriterdLostAck_percent = -1.0; -EventSelector.WriterdSendFail_percent = -1.0; -EventSelector.WriterdConnection = "storewrt.lbdaq.cern.ch:45247"; -EventSelector.WriterdConnection = "store15-d1:45247"; -EventSelector.RundbConnection = "http://10.128.40.70:8080"; - -Logger.OutputLevel = 1; -Logger.LockedOutput = true; \ No newline at end of file diff --git a/Online/FarmConfig/options/VeloCalibWriteReg.opts b/Online/FarmConfig/options/VeloCalibWriteReg.opts deleted file mode 100755 index 3396f400d54162ab6067bfe5edd29e20f14c4a37..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/VeloCalibWriteReg.opts +++ /dev/null @@ -1,17 +0,0 @@ -// MSF: 04/12/2016: NEW Dataflow task type ! -#pragma print off -// -// Velo event writer running on the CALIBRATION farm -// -OnlineEnv.LogFifoName = "$LOGFIFO"; -#include "$INFO_OPTIONS" -#include "$ONLINETASKS/options/DFWRT.opts" -// -MBM.Buffers = {"Output"}; -EventSelector.Input = "Output"; -EventSelector.REQ1 = "EvType=2;TriggerMask=0x0,0x0,0x0,0x800;VetoMask=0,0,0,0;MaskType=ANY;UserType=USER;Frequency=PERC;Perc=100.0"; -// -Writer.RunFileTimeoutSeconds = 60; -Writer.StreamID = "CALIB"; -Writer.MaxFileSizeMB = 500; -Writer.UpdatePeriod = 30; diff --git a/Online/FarmConfig/options/WRTHlt1All.opts b/Online/FarmConfig/options/WRTHlt1All.opts deleted file mode 100644 index 94cb60ac8ebe22213059e884e6caaac36c31f154..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/WRTHlt1All.opts +++ /dev/null @@ -1,7 +0,0 @@ -#include "$FARMCONFIGROOT/options/StorageWriterBasic.opts" -EventSelector.WriterdConnection = "storewrt.lbdaq.cern.ch:45247"; -EventSelector.WriterdConnection = "store15-d1:45247"; -EventSelector.RundbConnection = "http://10.128.40.70:8080"; -EventSelector.Output = { - "OnlineStreams": ["Events", "Lumi"] -}; diff --git a/Online/FarmConfig/options/genAdder.opts b/Online/FarmConfig/options/genAdder.opts deleted file mode 100755 index 43c86c9d254ace713760e600a948656263995075..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/genAdder.opts +++ /dev/null @@ -1,5 +0,0 @@ -// Job options file. Simple Online monitoring example -//============================================================== -#include "$AdderOptsFile" -#include "$AdderStaticOpts" -MessageSvc.OutputLevel = 3; diff --git a/Online/FarmConfig/options/pooper.opts b/Online/FarmConfig/options/pooper.opts deleted file mode 100755 index 43b020daa0f74db91f730ad9ca7673e8a7c6e978..0000000000000000000000000000000000000000 --- a/Online/FarmConfig/options/pooper.opts +++ /dev/null @@ -1,185 +0,0 @@ -// Job options file. Simple Online monitoring example -//============================================================== -#include "$INFO_OPTIONS" -#include "/group/online/dataflow/options/LHCb/LHCb_Tell1Boards.opts" -ApplicationMgr.ExtSvc += { - "MEPSvc/MEPrxCountPub" - }; -ApplicationMgr.ExtSvc += { - "MEPrxThrottleSvc" - }; -ApplicationMgr.ExtSvc += { - "RateSvc/HLTRater" - }; -ApplicationMgr.ExtSvc += { -// "GenStatSvc/EVTProd", - "GenStatSvc/DiskWR" - }; -ApplicationMgr.ExtSvc += { - "GenStatSvc/HLT1Pub" - }; -ApplicationMgr.ExtSvc += { - "BusyPub" - }; -ApplicationMgr.ExtSvc += { - "DiskWrPub" - }; -ApplicationMgr.ExtSvc += {"CntrPub/AlWr"}; -ApplicationMgr.ExtSvc += {"CntrPub/HLT1Writer"}; -ApplicationMgr.ExtSvc += {"CntrPub/HLT1Writer1"}; -ApplicationMgr.ExtSvc += {"CntrPub/HLT1Sender"}; -//ApplicationMgr.ExtSvc += { -// "MoorePub/Moore1s" -// }; -//ApplicationMgr.ExtSvc += { -// "MoorePub/Moore2s" -// }; - -ApplicationMgr.EventLoop = "LHCb::OnlineRunable/EmptyEventLoop"; -ApplicationMgr.Runable = "LHCb::OnlineRunable/Runable"; -ApplicationMgr.HistogramPersistency = "NONE"; -ApplicationMgr.EvtSel = "NONE"; -Runable.Wait = 3; // 1 of running as daemon -MessageSvc.OutputLevel = 3; //@OnlineEnv.OutputLevel; - -//MessageSvc.fifoPath = "$LOGFIFO"; -HistogramPersistencySvc.Warnings = false; - - -MEPrxCountPub.MyName = "<part>_X_MEPrx"; -MEPrxCountPub.PartitionName = @OnlineEnv.PartitionName; -MEPrxCountPub.TaskPattern = "MON_<part>_HLT02_PartAdder_(.*)"; -MEPrxCountPub.ServicePattern = "MON_<part>_MEPrx_00/Counter/"; -MEPrxCountPub.AdderClass = "Counter"; -MEPrxCountPub.InDNS = "mona08"; -MEPrxCountPub.Tell1List=@OnlineEnv.Tell1Boards; -MEPrxCountPub.TrendingOn = true; -MEPrxCountPub.OutDNS = "mona08"; - -MEPrxThrottleSvc.MyName = "<part>_X_MEPrxThr"; -MEPrxThrottleSvc.PartitionName = @OnlineEnv.PartitionName; -MEPrxThrottleSvc.TaskPattern = "MON_<part>_HLT02_PartAdder_(.*)"; -MEPrxThrottleSvc.ServicePattern = "MON_<part>_MEPrx_00/Counter/"; -MEPrxThrottleSvc.AdderClass = "Counter"; -MEPrxThrottleSvc.InDNS = "mona08"; -MEPrxThrottleSvc.TrendingOn = false; -MEPrxThrottleSvc.OutDNS = "ecs03"; - -HLTRater.MyName = "<part>_X_Rater"; -HLTRater.PartitionName = @OnlineEnv.PartitionName; -HLTRater.TaskPattern = "MON_<part>_HLT02_PartAdder_(.*)"; -HLTRater.ServicePattern = "MON_<part>_Moore1_00/Counter/"; -HLTRater.AdderClass = "Counter"; -HLTRater.InDNS = "mona08"; -HLTRater.TrendingOn = true; -HLTRater.OutDNS = "mona08"; - -//EVTProd.MyName = "<part>_X_EVTProd"; -//EVTProd.ServicePrefix = "Stat/<part>_X_EVTProd"; -//EVTProd.PartitionName = @OnlineEnv.PartitionName; -//EVTProd.TaskPattern = "<part>_HLT02_PartAdder_(.*)"; -//EVTProd.ServicePattern = "MON_<part>_evtprod_00/Counter/"; -//EVTProd.AdderClass = "Counter"; -//EVTProd.InDNS = "mona08"; - -DiskWR.MyName = "<part>_X_DiskWR"; -DiskWR.ServicePrefix = "Stat/<part>_X_DiskWR"; -DiskWR.PartitionName = @OnlineEnv.PartitionName; -DiskWR.TaskPattern = "MON_<part>_HLT02_PartAdder_(.*)"; -DiskWR.ServicePattern = "MON_<part>_Sender_00/Counter/"; -//DiskWR.AdderClass = "Counter"; -DiskWR.InDNS = "mona08"; -DiskWR.OutDNS = "mona08"; - -HLT1Pub.MyName = "<part>_X_HLT1"; -HLT1Pub.ServicePrefix = "Stat/<part>_X_HLT1"; -HLT1Pub.PartitionName = @OnlineEnv.PartitionName; -HLT1Pub.TaskPattern = "MON_<part>_HLT02_PartAdder_(.*)"; -HLT1Pub.ServicePattern = "MON_<part>_Moore1_00/Counter/"; -HLT1Pub.AdderClass = "Counter"; -HLT1Pub.InDNS = "mona08"; -HLT1Pub.OutDNS = "mona08"; - -BusyPub.MyName = "<part>_X_BusyPub"; -BusyPub.PartitionName = @OnlineEnv.PartitionName; -BusyPub.TaskPattern = "MON_<part>_HLT02_PartAdder_(.*)"; -BusyPub.ServicePattern = "MON_<part>_Busy_00/Counter/"; -BusyPub.AdderClass = "Counter"; -BusyPub.InDNS = "mona08"; -BusyPub.TrendingOn = true; -BusyPub.OutDNS = "mona08"; - -DiskWrPub.MyName = "<part>_X_DiskWrPub"; -DiskWrPub.PartitionName = @OnlineEnv.PartitionName; -DiskWrPub.TaskPattern = "MON_<part>_HLT02_PartAdder_(.*)"; -DiskWrPub.ServicePattern = "MON_<part>_(.*)Sender_00/Counter/"; -DiskWrPub.AdderClass = "Counter"; -DiskWrPub.InDNS = "mona08"; -DiskWrPub.TrendingOn = true; -DiskWrPub.OutDNS = "mona08"; - -AlWr.MyName = "<part>_X_AlWr"; -AlWr.PartitionName = @OnlineEnv.PartitionName; -AlWr.TaskPattern = "MON_<part>_HLT02_PartAdder_(.*)"; -AlWr.ServicePattern = "MON_<part>_AlignWriter_00/Counter/"; -AlWr.AdderClass = "Counter"; -AlWr.CounterPattern = "AlignDataWriter_(.*)/EvtsOut"; -AlWr.InDNS = "mona08"; -AlWr.OutDNS = "mona08";//AlignDataWriter_Velo/EvtsOut - -HLT1Writer.MyName = "<part>_X_HLT1Writer"; -HLT1Writer.PartitionName = @OnlineEnv.PartitionName; -HLT1Writer.TaskPattern = "MON_<part>_HLT02_PartAdder_(.*)"; -HLT1Writer.ServicePattern = "MON_<part>_DskWriter_00/Counter/"; -HLT1Writer.AdderClass = "Counter"; -HLT1Writer.CounterPattern = "(.*)DskWriter(.*)EvtsOut"; -HLT1Writer.InDNS = "mona08"; -HLT1Writer.OutDNS = "mona08"; - -HLT1Writer1.MyName = "<part>_X_HLT1Writer1"; -HLT1Writer1.PartitionName = @OnlineEnv.PartitionName; -HLT1Writer1.TaskPattern = "MON_<part>_HLT02_PartAdder_(.*)"; -HLT1Writer1.ServicePattern = "MON_<part>_DWHiMu_00/Counter/"; -HLT1Writer1.AdderClass = "Counter"; -HLT1Writer1.CounterPattern = "(.*)DWHiMu(.*)EvtsOut"; -HLT1Writer1.InDNS = "mona08"; -HLT1Writer1.OutDNS = "mona08"; - -HLT1Sender.MyName = "<part>_X_HLT1Sender"; -HLT1Sender.PartitionName = @OnlineEnv.PartitionName; -HLT1Sender.TaskPattern = "MON_<part>_HLT02_PartAdder_(.*)"; -HLT1Sender.ServicePattern = "MON_<part>_HLT1Sender_00/Counter/"; -HLT1Sender.AdderClass = "Counter"; -HLT1Sender.CounterPattern = "Prescaler/(.*)"; -HLT1Sender.InDNS = "mona08"; -HLT1Sender.OutDNS = "mona08"; -HLT1Sender.TrendingOn = true; - -//OvrPub.MyName = "<part>_X_OvrPub"; -//OvrPub.PartitionName = @OnlineEnv.PartitionName; -//OvrPub.TaskPattern = "PART[0-9][0-9]_Adder_(.*)"; -//OvrPub.ServicePattern = "MON_<part>_hlt01_OverflowWr_00/Counter/"; -//OvrPub.AdderClass = "Counter"; -//OvrPub.InDNS = "mona08"; -//OvrPub.TrendingOn = true; - -//Moore1s.MyName = "<part>_X_Moore1s"; -//Moore1s.PartitionName = @OnlineEnv.PartitionName; -//Moore1s.TaskPattern = "MON_<part>_HLT02_PartAdder_(.*)"; -//Moore1s.ServicePattern = "MON_<part>_Moore1_00/Counter/"; -//Moore1s.AdderClass = "Counter"; -//Moore1s.TrendName = "Moore1s"; -//Moore1s.InDNS = "mona08"; -//Moore1s.OutDNS = "mona08"; -//Moore1s.TrendingOn = true; - -//Moore2s.MyName = "<part>_X_Moore2s"; -//Moore2s.PartitionName = @OnlineEnv.PartitionName; -//Moore2s.TaskPattern = "MON_<part>_HLT02_PartAdder_(.*)"; -//Moore2s.ServicePattern = "MON_<part>_Moore2_00/Counter/"; -//Moore2s.AdderClass = "Counter"; -//Moore2s.TrendName = "Moore2s"; -//Moore2s.InDNS = "mona08"; -//Moore2s.OutDNS = "mona08"; -//Moore2s.TrendingOn = true; - diff --git a/Online/Gaucho/Gaucho/IGauchoMonitorSvc.h b/Online/Gaucho/Gaucho/IGauchoMonitorSvc.h index 122b437b33644989cf77b7982f97bda811e7a82c..4f12206e6f736e15909bfb50849281e5954ee5e5 100644 --- a/Online/Gaucho/Gaucho/IGauchoMonitorSvc.h +++ b/Online/Gaucho/Gaucho/IGauchoMonitorSvc.h @@ -18,9 +18,9 @@ #include <string> #include <atomic> // from Gaudi -#include "GaudiKernel/IMonitorSvc.h" #include <Gaudi/Accumulators.h> #include <Gaudi/MonitoringHub.h> +#include <GaudiKernel/IMonitorSvc.h> class DimService; static const InterfaceID IID_IGauchoMonitorSvc("IGauchoMonitorSvc", 1, 0); diff --git a/Online/Gaucho/src/components/UpdateAndReset.cpp b/Online/Gaucho/src/components/UpdateAndReset.cpp index 67e1d97375b3690279ee485cd6a0019bfe10b49a..fe1d31b8a220083950053a54a5eadb75a8a0e56c 100644 --- a/Online/Gaucho/src/components/UpdateAndReset.cpp +++ b/Online/Gaucho/src/components/UpdateAndReset.cpp @@ -24,13 +24,10 @@ // ==================================================================== #include "UpdateAndReset.h" + // Include files -#include <GaudiKernel/SmartDataPtr.h> -#include <GaudiKernel/MsgStream.h> -#include <GaudiKernel/IDataProviderSvc.h> #include <GaudiKernel/IDataManagerSvc.h> #include <GaudiKernel/IRegistry.h> -#include <GaudiKernel/IHistogramSvc.h> #include <GaudiKernel/IIncidentSvc.h> #include <GaudiUtils/Aida2ROOT.h> #include <Gaucho/Utilities.h> @@ -120,8 +117,7 @@ StatusCode UpdateAndReset::start() m_one = 1; m_gauchoMonitorSvc = monitorSvc(); if ( !m_gauchoMonitorSvc ) { - msg << MSG::FATAL << "Unable to locate the IGauchoMonitorSvc interface." - << endmsg; + fatal() << "Unable to locate the IGauchoMonitorSvc interface." << endmsg; return StatusCode::FAILURE; } @@ -157,9 +153,7 @@ StatusCode UpdateAndReset::start() declareInfo("Tasks", m_one, "NumberOfTasks"); if (1 == m_saveHistograms) { div_t divresult = div(m_saverCycle, m_desiredDeltaTCycle); - if (0 == divresult.rem) { - } - else { + if ( 0 != divresult.rem ) { m_saverCycle = divresult.quot * m_desiredDeltaTCycle; } } @@ -204,8 +198,7 @@ StatusCode UpdateAndReset::execute(EventContext const& /* ctxt */) const return This->do_execute(runno); } } - MsgStream msg(msgSvc(), name()); - msg << MSG::DEBUG << "ODIN bank not found at location " << m_rawData << endmsg; + debug() << "ODIN bank not found at location " << m_rawData << endmsg; return StatusCode::FAILURE; } MsgStream msg(msgSvc(), name()); diff --git a/Online/GauchoAppl/GauchoAppl/AddTimer.h b/Online/GauchoAppl/GauchoAppl/AddTimer.h index 809aab1cfb3cc87c507c4cb8d3c21df5a4d30974..f9eb6affe4b3d6518cbb689410d8df167014b23f 100644 --- a/Online/GauchoAppl/GauchoAppl/AddTimer.h +++ b/Online/GauchoAppl/GauchoAppl/AddTimer.h @@ -19,21 +19,12 @@ class MonAdder; class AddTimer : public GenTimer { MonAdder *m_owner; - bool m_stopped; + bool m_stopped; public: AddTimer(MonAdder *tis, int period = 5, int typ = 0); virtual ~AddTimer(void); void timerHandler ( void ) override; - void Stop(); - void stop() - { - m_stopped = true; - Stop(); - } - void start(int dt) - { - m_stopped = false; - Start(dt); - } + void stop() override; + void startPeriodic(int dt) override; }; #endif // ONLINE_GAUCHO_ADDTIMER_H diff --git a/Online/GauchoAppl/GauchoAppl/AdderSvc.h b/Online/GauchoAppl/GauchoAppl/AdderSvc.h index 7021d814edbe91163aff6d9f3f70f73f86a8ae80..c555d0088e6a36c90699203ef52453cfc9cf590b 100644 --- a/Online/GauchoAppl/GauchoAppl/AdderSvc.h +++ b/Online/GauchoAppl/GauchoAppl/AdderSvc.h @@ -27,6 +27,7 @@ class IHistogramSvc; class DimServerDns; namespace AIDA { class IHistogram1D; } + class AdderSvc : public Service, virtual public IIncidentListener { public: diff --git a/Online/GauchoAppl/GauchoAppl/MonAdder.h b/Online/GauchoAppl/GauchoAppl/MonAdder.h index be2989c71bb27ec14480b302d62f955a2835806d..589c2287c6e0fd30230dd67361a535d6043e0437 100644 --- a/Online/GauchoAppl/GauchoAppl/MonAdder.h +++ b/Online/GauchoAppl/GauchoAppl/MonAdder.h @@ -156,7 +156,6 @@ namespace AIDA class IGauchoMonitorSvc; class TimeoutCmd; class AdderSvc; -class DimServiceDns; class ClassDescriptor; class ClassMap; @@ -195,13 +194,8 @@ public: void *PauseArg; void (*CycleFn)(void*,void*,int, MonMap *, MonAdder *); void (*PauseFn)(void*); -// void **m_buffadd; -// void *m_buffer; -// int m_buffersize; -// int m_usedSize; bool m_DebugOn; int m_FragmentSize; -// FILE *logFile; std::string m_MyName; std::string m_NamePrefix; std::string m_outsvcname; @@ -216,15 +210,9 @@ public: std::string m_servicePattern; boost::regex m_taskexp; boost::regex m_serviceexp; -// long long m_reference; -// long long m_updateStamp; MonMap m_itemmap; -// size_t m_received; -// int m_added; std::string m_name; -// ObjService *m_outservice; ObjRPC *m_rpc; -// ObjSerializer *m_ser; ObjSerializer *m_RPCser; std::string m_serviceName; std::string m_cmdname; @@ -233,25 +221,22 @@ public: bool m_noRPC; bool m_Test; bool m_SaveonUpdate; -// unsigned long long m_time0; DimBuffBase *m_RateBuff; bool m_locked; -// std::string m_MyName; -// std::string m_NamePrefix; DimBuffBase *m_oldProf; AdderSvc *m_parentAdderSvc; bool m_RunAware = false; RunManager m_RunManager; public: std::shared_ptr<DimServerDns> m_ServiceDns; -// TimeoutCmd *m_Dimcmd; BRTLLock *m_lockid; BRTLLock m_maplock; bool m_dohisto; -// bool m_timeout; AIDA::IHistogram1D *m_histo; IGauchoMonitorSvc *m_monsvc; + DimServerDns* serviceDns() { return m_ServiceDns.get(); } + virtual void add(void *buffer, int siz, MonInfo *h)=0; virtual void basicAdd(void *buffer, int siz, MonInfo *h); virtual void BasicAdd(void *buffer, int siz, MonInfo *h); @@ -268,10 +253,7 @@ public: void setParent(AdderSvc *parent){m_parentAdderSvc = parent;return;} void setSaveonUpdate(bool SaveonUpdate){m_SaveonUpdate = SaveonUpdate;return;} INServiceDescr *findINService(std::string); -// OUTServiceDescr *findOUTService(std::string servc); virtual void Configure(); -// virtual void TaskHandler(char *, int); -// virtual void ServiceHandler(DimInfo *, std::string &, char *, int); virtual void NewService(DimInfo *myInfo, std::string &TaskName, std::string &ServiceName); virtual void RemovedService(DimInfo *, std::string &TaskName, std::string &ServiceName); virtual void SynchronizeServices(std::string taskname, std::vector<std::string>&service_list); @@ -291,7 +273,7 @@ public: } m_isSaver = p; return; - }; + } int Lock() { if (m_lockid != 0) @@ -300,7 +282,7 @@ public: return status; } return 0; - }; + } int UnLock() { if (m_lockid != 0) @@ -309,18 +291,18 @@ public: return status; } return 0; - }; + } int LockMap() { int status = m_maplock.lockMutex(); return status; - }; + } int UnLockMap() { int status = m_maplock.unlockMutex(); return status; - }; + } void dumpServices(); void start(); void stop(); @@ -329,7 +311,6 @@ public: virtual void I_update(bool force=false); }; - class TimeoutCmd : public DimCommand { public: diff --git a/Online/GauchoAppl/GauchoAppl/SaveTimer.h b/Online/GauchoAppl/GauchoAppl/SaveTimer.h index 07ff208e556286b4fbf0450fabc0da7dc311e3ba..50fa5e0249aea53bcdcebe6ebad374620469b3d6 100644 --- a/Online/GauchoAppl/GauchoAppl/SaveTimer.h +++ b/Online/GauchoAppl/GauchoAppl/SaveTimer.h @@ -14,67 +14,44 @@ #include "Gaucho/GenTimer.h" #include "GauchoAppl/MonAdder.h" #include "GauchoAppl/HistAdder.h" + class MonSubSys; class DimService; +class DimServerDns; class TFile; -class SaveTimer : public GenTimer -{ + +class SaveTimer : public GenTimer { public: - MonAdder *m_Adder; - void *m_buffadd; - int m_bsiz; -#if 0 std::string m_filename; std::string m_rootdir; - std::string m_fnpatt; std::string m_partname; std::string m_taskname; - std::string m_infoFileStatus; - bool m_EOR; -public: - SaveTimer(MonAdder *tis, int period = 900); - ~SaveTimer(void); - void timerHandler ( void ) override; -// void Stop(); - void SavetoFile(void *buff); - void setRootDir(std::string &p){m_rootdir = p;return;}; - void setPartName(std::string &p){ m_partname= p;return;}; - void setTaskName(std::string &p){m_taskname = p;return;}; - void setEOR(bool flg){m_EOR = flg;return;}; - DimService *getSaveSetService(){return m_filenamesvc;}; - void setSaveSetService(); - void setSaveSetService(DimService *svc){m_filenamesvc = svc;return;}; - DimService *m_filenamesvc; -#endif - void *m_prevbuff; - int m_prevsiz; - std::string m_filename; - std::string m_rootdir; - std::string m_partname; - std::string m_taskname; - bool m_EOR; -// MonSys *m_MonSys; std::string m_currDir; std::string m_currFileName; - TFile *m_currFile; -public: std::string m_infoFileStatus; - DimService *getSaveSetService(){return m_filenamesvc;}; - void setSaveSetService(); - void setSaveSetService(DimService *svc){m_filenamesvc = svc;return;}; + std::unique_ptr<TFile> m_currFile; + std::unique_ptr<DimService> m_filenamesvc; + std::pair<size_t, std::unique_ptr<unsigned char[]> > m_buffer; + MonAdder *m_adder {nullptr}; + bool m_EOR; + +public: + + public: SaveTimer(MonAdder *tis, int period = 900); ~SaveTimer(void); - void timerHandler ( void ) override; - void Stop(); - void SavetoFile(void *buff); + DimService *getSaveSetService(){ return m_filenamesvc.get(); }; + void setSaveSetService(DimServerDns* dns); + void setSaveSetService(DimService *svc){ m_filenamesvc.reset(svc); } + void timerHandler() override; + void stop() override; + void savetoFile(const void *buff); void setRootDir(std::string &p){m_rootdir = p;return;}; void setPartName(std::string &p){ m_partname= p;return;}; void setTaskName(std::string &p){m_taskname = p;return;}; -// void setMonSys(MonSys *p){m_MonSys = p;return;}; void setEOR(bool flg){m_EOR = flg;return;}; void makeDirs(int runno); void openFile(); void closeFile(); - DimService *m_filenamesvc; }; #endif diff --git a/Online/GauchoAppl/src/AddTimer.cpp b/Online/GauchoAppl/src/AddTimer.cpp index 372c1ad1d5b7be5d1a708ab12dd011f7d2af9e05..6aca2ee989a32b68306340b4a6aee33d5f938fbf 100644 --- a/Online/GauchoAppl/src/AddTimer.cpp +++ b/Online/GauchoAppl/src/AddTimer.cpp @@ -34,8 +34,14 @@ void AddTimer::timerHandler ( void ) } } -void AddTimer::Stop() +void AddTimer::startPeriodic(int dt) +{ + m_stopped = false; + this->GenTimer::startPeriodic(dt); +} + +void AddTimer::stop() { m_stopped = true; - GenTimer::Stop(); + this->GenTimer::stop(); } diff --git a/Online/GauchoAppl/src/AdderSvc.cpp b/Online/GauchoAppl/src/AdderSvc.cpp index 8bcfb7bf2ba69f8739592a8495f6230bf10897bd..283fa278447b9654cf8a74bb597e4988236c661c 100644 --- a/Online/GauchoAppl/src/AdderSvc.cpp +++ b/Online/GauchoAppl/src/AdderSvc.cpp @@ -9,17 +9,19 @@ // Author : B.Jost // //========================================================================== -#include "GauchoAppl/AdderSvc.h" -#include "GauchoAppl/HistAdder.h" -#include "GauchoAppl/CounterAdder.h" -#include "GauchoAppl/SaveTimer.h" -#include "GauchoAppl/AdderSys.h" -#include "Gaucho/Utilities.h" -#include "Gaucho/IGauchoMonitorSvc.h" -#include "Gaucho/SegvHandler.h" -#include "GaudiKernel/IIncidentSvc.h" -#include "GaudiKernel/IHistogramSvc.h" -#include "AIDA/IHistogram.h" + +#include <GauchoAppl/AdderSvc.h> +#include <GauchoAppl/HistAdder.h> +#include <GauchoAppl/CounterAdder.h> +#include <GauchoAppl/SaveTimer.h> +#include <GauchoAppl/AdderSys.h> +#include <Gaucho/Utilities.h> +#include <Gaucho/IGauchoMonitorSvc.h> +#include <Gaucho/SegvHandler.h> +#include <GaudiKernel/IIncidentSvc.h> +#include <GaudiKernel/IHistogramSvc.h> +#include <AIDA/IHistogram.h> +#include <Gaucho/MyDimErrorHandler.h> namespace { void EORSaver(void *arg, void* /* b */, int /* bsiz */, MonMap* /* m */, MonAdder* /* caller */) @@ -39,7 +41,6 @@ namespace ADDERSVC tis->gotoPause(); } } -#include "Gaucho/MyDimErrorHandler.h" AdderSvc::AdderSvc(const std::string& name, ISvcLocator* sl) : Service(name,sl),m_incidentSvc(0) { @@ -168,7 +169,7 @@ StatusCode AdderSvc::start() std::string myservicename; std::string nodename = RTL::nodeNameShort(); - StatusCode status =Service::start(); + StatusCode status = Service::start(); if ( !status.isSuccess() ) {} if (m_errh == 0) m_errh = new MyDimErrorHandler(); toLowerCase(m_TaskPattern); @@ -220,30 +221,17 @@ StatusCode AdderSvc::start() toLowerCase(ddns); StringReplace(m_InputDNS,"<node>",nodename); StringReplace(m_InputDNS,"<dns>",ddns); - if (m_OutputDNS.length() != 0) - { + if (m_OutputDNS.length() != 0) { StringReplace(m_OutputDNS,"<node>",nodename); StringReplace(m_OutputDNS,"<dns>",ddns); } - else - { + else { m_OutputDNS = ddns; } - if (m_OutputDNS != ddns) - { + if (m_OutputDNS != ddns) { + m_standardOutDNS = false; + m_ServiceDns = this->m_AdderSys->getDNS(m_OutputDNS); m_standardOutDNS = false; -// if (m_ServiceDns == 0) -// { - m_ServiceDns = this->m_AdderSys->getDNS(m_OutputDNS); -// if (m_ServiceDns == 0) -// { -// m_ServiceDns = new DimServerDns(m_OutputDNS.c_str()); -// this->m_AdderSys->addDNS(m_OutputDNS,m_ServiceDns); -// m_ServiceDns->autoStartOn(); -// DimServer::start(m_ServiceDns,(char*) (("MON_" + RTL::processName()).c_str())); -// } - m_standardOutDNS = false; -// } } m_errh->start(); if (m_started) return StatusCode::SUCCESS; @@ -310,17 +298,17 @@ StatusCode AdderSvc::start() m_SaveTimer->setRootDir(m_SaveRootDir); m_SaveTimer->setTaskName(m_SaverTaskName); m_SaveTimer->setEOR(false); - m_SaveTimer->setSaveSetService(); - m_SaveTimer->Start(); + m_SaveTimer->setSaveSetService(m_adder->serviceDns()); + m_SaveTimer->start(); } - if (m_AdderClass == "hists") + if ( m_AdderClass == "hists" ) { - m_EoRadder = new HistAdder((char*)myservicename.c_str(), (char*)"EOR"); + m_EoRadder = new HistAdder(myservicename.c_str(), "EOR"); } - else if (m_AdderClass == "counter") + else if ( m_AdderClass == "counter" ) { - m_EoRadder = new CounterAdder((char*)myservicename.c_str(), (char*)"EOR"); + m_EoRadder = new CounterAdder(myservicename.c_str(), "EOR"); } m_EoRadder->m_Test = m_Test; m_EoRadder->m_DebugOn = m_DebugOn; @@ -337,7 +325,6 @@ StatusCode AdderSvc::start() m_EoRadder->m_noRPC = true; if (m_EoRTmoFactor == 0) { - m_EoRadder->m_rectmo = 500*m_recvtmo; } else @@ -380,9 +367,8 @@ StatusCode AdderSvc::stop() IGauchoMonitorSvc* psvc = dynamic_cast<IGauchoMonitorSvc*>(m_pMonitorSvc); if (psvc) psvc->resetHistos(this); } - if (m_isSaver) - { -// m_SaveTimer->Stop(); + if (m_isSaver) { +// m_SaveTimer->stop(); } return Service::stop(); } @@ -418,7 +404,7 @@ StatusCode AdderSvc::finalize() //printf("AdderSvc: Locking DIM\n"); if (m_SaveTimer != 0) { - m_SaveTimer->Stop(); + m_SaveTimer->stop(); deletePtr(m_SaveTimer); } if (m_AdderSys != &AdderSys::Instance()) @@ -444,18 +430,16 @@ StatusCode AdderSvc::finalize() } return Service::finalize(); } + void AdderSvc::gotoPause() { m_incidentSvc->fireIncident(Incident(name(),"DAQ_PAUSE")); } + void AdderSvc::handle(const Incident& inc) { if (inc.type() == "APP_RUNNING") { m_AdderSys->start(); } -// else if (inc.type() == "APP_STOPPED") -// { -// m_AdderSys->stop(); -// } } diff --git a/Online/GauchoAppl/src/HistAdder.cpp b/Online/GauchoAppl/src/HistAdder.cpp index 4433537c4bdfda17010459310c0381ca17bd5c74..308dcb9950aabd0885ec0eb7f17437a2010fb2b6 100644 --- a/Online/GauchoAppl/src/HistAdder.cpp +++ b/Online/GauchoAppl/src/HistAdder.cpp @@ -48,17 +48,10 @@ extern "C" HistAdder::HistAdder(const char *myName, const char *serviceName) { m_serviceName = serviceName; -// m_serviceName = std::string("/Histos/") + serviceName; m_MyName = myName; m_type = ADD_HISTO; m_oldProf = 0; -// m_updated = false; AdderSys::Instance().gg_AdderList.push_back(this); -// std::string fn; -// fn = "/group/online/dataflow/logs/Adders/"; -// fn+= myName; -// fn = fn+"_Adder.log"; -// logFile =fopen(fn.c_str(),"w"); } HistAdder::~HistAdder() @@ -77,7 +70,6 @@ void HistAdder::add(void *buff, int siz, MonInfo *h) void HistAdder::addBuffer(void *buff, int siz,MonInfo* /* HTsk */) { -// //printf("Adding %s\n",h->m_TargetService.c_str()); MonMap hmap; hmap.clear(); void *bend = AddPtr(buff,siz); diff --git a/Online/GauchoAppl/src/MonAdder.cpp b/Online/GauchoAppl/src/MonAdder.cpp index 3b2f678b75cf63820d437d8b4a2f471373fbf6fc..723d397333c6e6080854043373df2d39fa0f6b45 100644 --- a/Online/GauchoAppl/src/MonAdder.cpp +++ b/Online/GauchoAppl/src/MonAdder.cpp @@ -10,29 +10,31 @@ // //========================================================================== // workaround for https://its.cern.ch/jira/browse/GAUDI-1168 -#include "GaudiKernel/Algorithm.h" -#include "dim/dim.h" +#include <GaudiKernel/Algorithm.h> +#include <dim/dim.h> -#include "GauchoAppl/MonAdder.h" -#include "Gaucho/MonTypes.h" -#include "Gaucho/SerialHeader.h" -#include "Gaucho/dimhist.h" -#include "Gaucho/Utilities.h" -#include "GauchoAppl/AdderSys.h" -#include "GauchoAppl/AddSerializer.h" -#include "Gaucho/ObjRPC.h" -#include "GauchoAppl/AddTimer.h" -#include "Gaucho/IGauchoMonitorSvc.h" -#include "AIDA/IHistogram1D.h" -#include "GauchoAppl/AdderSvc.h" -#include "GauchoAppl/SaveTimer.h" -#include "WT/wtdef.h" -#include "GauchoAppl/ClassDescriptor.h" +#include <GauchoAppl/MonAdder.h> +#include <Gaucho/MonTypes.h> +#include <Gaucho/SerialHeader.h> +#include <Gaucho/dimhist.h> +#include <Gaucho/Utilities.h> +#include <GauchoAppl/AdderSys.h> +#include <GauchoAppl/AddSerializer.h> +#include <Gaucho/ObjRPC.h> +#include <GauchoAppl/AddTimer.h> +#include <Gaucho/IGauchoMonitorSvc.h> +#include <AIDA/IHistogram1D.h> +#include <GauchoAppl/AdderSvc.h> +#include <GauchoAppl/SaveTimer.h> +#include <WT/wtdef.h> +#include <GauchoAppl/ClassDescriptor.h> #include <exception> + static int mpty; using namespace std; using namespace boost; -//DimServerDns *MonAdder::m_ServiceDns = 0; + + string getClassName(string &service) { size_t dot; @@ -489,10 +491,9 @@ void MonAdder::SynchronizeServices(std::string taskname, std::vector<std::string { unsigned int i; bool fnd = false; + bool status; std::string le; std::string tskname,tgen; -// ::lib_rtl_output(LIB_RTL_ERROR,"In SynchronizeServices: Taskname = %s, expected task name =%s\n",taskname.c_str(),m_taskPattern.c_str()); - bool status; boost::cmatch what; try { @@ -783,7 +784,7 @@ void MonAdder::start() { ::lib_rtl_output(LIB_RTL_INFO,"MonAdder MonAdder::start called for Service %s\n", m_name.c_str() ); - m_timer->start(int(m_rectmo)); + m_timer->startPeriodic(m_rectmo); } } void MonAdder::stop() @@ -1234,7 +1235,7 @@ void MonAdder::BasicAdd(void *buff, int siz, MonInfo *h) ::lib_rtl_output(LIB_RTL_INFO,"MonAdder: service %s Header Version %d. Update Interval %d: Setting timeout to %d seconds\n", this->m_servicePattern.c_str(),header->version,header->updateInterval,int(tmo)); } - this->m_timer->start(int(tmo)); + this->m_timer->startPeriodic(tmo); } else { @@ -1244,7 +1245,7 @@ void MonAdder::BasicAdd(void *buff, int siz, MonInfo *h) this->m_servicePattern.c_str(),header->version,header->updateInterval); } } -// this->m_timer->start(int(tmo)); +// this->m_timer->startPeriodic(tmo); } else @@ -1256,7 +1257,7 @@ void MonAdder::BasicAdd(void *buff, int siz, MonInfo *h) ::lib_rtl_output(LIB_RTL_INFO,"MonAdder: service %s Header Version %d. Update Interval %d: Setting timeout to %d seconds\n", this->m_servicePattern.c_str(),header->version,header->updateInterval,int(m_rectmo)); } - this->m_timer->start(int(m_rectmo)); + this->m_timer->startPeriodic(m_rectmo); } else { @@ -1474,7 +1475,7 @@ void MonAdder::basicAdd(void *buff, int siz, MonInfo *h) ::lib_rtl_output(LIB_RTL_INFO,"MonAdder: service %s Header Version %d. Update Interval %d: Setting timeout to %d seconds\n", this->m_servicePattern.c_str(),header->version,header->updateInterval,int(tmo)); } - this->m_timer->start(int(tmo)); + this->m_timer->startPeriodic(tmo); } else { @@ -1484,7 +1485,7 @@ void MonAdder::basicAdd(void *buff, int siz, MonInfo *h) this->m_servicePattern.c_str(),header->version,header->updateInterval); } } -// this->m_timer->start(int(tmo)); +// this->m_timer->startPeriodic(tmo); } else @@ -1496,7 +1497,7 @@ void MonAdder::basicAdd(void *buff, int siz, MonInfo *h) ::lib_rtl_output(LIB_RTL_INFO,"MonAdder: service %s Header Version %d. Update Interval %d: Setting timeout to %d seconds\n", this->m_servicePattern.c_str(),header->version,header->updateInterval,int(m_rectmo)); } - this->m_timer->start(int(m_rectmo)); + this->m_timer->startPeriodic(m_rectmo); } else { diff --git a/Online/GauchoAppl/src/SaveTimer.cpp b/Online/GauchoAppl/src/SaveTimer.cpp index 02522225f73225b1c23d8daf27e8391f7d65e9e3..884234f1659d7370b9d70c28f2df2cd45160c9b1 100644 --- a/Online/GauchoAppl/src/SaveTimer.cpp +++ b/Online/GauchoAppl/src/SaveTimer.cpp @@ -9,142 +9,91 @@ // Author : B.Jost // //========================================================================== -#include "GauchoAppl/SaveTimer.h" -//#include "Gaucho/MonSubSys.h" -#include "Gaucho/ObjService.h" -#include "stdio.h" -#include "TFile.h" -#include "TROOT.h" -#include "TThread.h" -#include "Gaucho/SerialHeader.h" -#include "Gaucho/MonHist.h" -#include "sys/time.h" -#include "sys/stat.h" -#include "sys/types.h" -#include "Gaucho/RootHists.h" -#include "Gaucho/Utilities.h" -#include "RTL/Lock.h" -#include "GauchoAppl/ClassDescriptor.h" -#include "Gaucho/HistSerDes.h" +#include <GauchoAppl/SaveTimer.h> +#include <Gaucho/ObjService.h> +#include <Gaucho/SerialHeader.h> +#include <Gaucho/MonHist.h> +#include <Gaucho/RootHists.h> +#include <Gaucho/Utilities.h> +#include <GauchoAppl/ClassDescriptor.h> +#include <Gaucho/HistSerDes.h> -SaveTimer::SaveTimer(MonAdder *add, int period) : GenTimer((void*)add,period*1000,TIMER_TYPE_PERIODIC) +#include <TFile.h> +#include <TROOT.h> +#include <TThread.h> + +#include <cstdio> +#include <sys/time.h> +#include <sys/stat.h> +#include <sys/types.h> + +SaveTimer::SaveTimer(MonAdder *add, int period) + : GenTimer((void*)add,period*1000,TIMER_TYPE_PERIODIC) { - m_Adder = add; + m_adder = add; m_dueTime = 0; - m_buffadd = 0; - m_bsiz = 0; - m_EOR=false; -// printf("==================SaveTimer Constructor.................%llu\n",m_period); + m_EOR = false; TH1D::SetDefaultSumw2(); TH2D::SetDefaultSumw2(); TProfile::SetDefaultSumw2(); - m_filenamesvc =0; m_dontdimlock = true; ROOT::GetROOT(); - if (!TThread::IsInitialized()) - { + if (!TThread::IsInitialized()) { TThread::Initialize(); } } SaveTimer::~SaveTimer( ) { - deletePtr(m_filenamesvc); + m_filenamesvc.reset(); } void SaveTimer::timerHandler(void) { -#if 0 - if (m_Adder->m_inputServicemap.empty()) - return; - m_Adder->Lock(); - if (!m_dontdimlock) dim_lock(); -// if (m_Adder->m_lockid != 0) -// { -// RTL::Lock alock(m_Adder->m_lockid); - if (m_Adder->m_usedSize == 0) - { - m_Adder->UnLock(); - return; - } - if (m_bsiz < m_Adder->m_usedSize) - { - if (m_buffadd != 0) - { - free(m_buffadd); - } - m_buffadd = malloc(m_Adder->m_usedSize); - m_bsiz = m_Adder->m_usedSize; - } - memcpy(m_buffadd, m_Adder->m_buffer, m_bsiz); - if (!m_dontdimlock) dim_unlock(); - m_Adder->UnLock(); -// } -// else -// { -// printf("ERROR !!!!!!!!!!!!!!!!!!!! Bad Logic... running a SaveTimer without an adder lock...\n"); -// return; -// } - SavetoFile(m_buffadd); -#endif m_currFile = 0; - if (m_Adder) - { + if (m_adder) { // Need protection against m_subsys==0: // If the save time runs, but no histograms were // ever published, m_subsys (histograms) is NULL! - m_Adder->Lock(); + m_adder->Lock(); if (!m_dontdimlock) dim_lock(); if (!m_dontdimlock) dim_unlock(); - m_Adder->UnLock(); - for (auto i =m_Adder->m_ClassMap->begin(); i!= m_Adder->m_ClassMap->end();i++) - { - int siz; - siz =i->second->m_buffersize;//m_outservice->m_ser->buffersize; - if (m_bsiz <siz) - { - if (m_buffadd != 0) - { - free(m_buffadd); - } - m_buffadd = malloc(siz); - m_bsiz = siz; + m_adder->UnLock(); + for (auto i =m_adder->m_ClassMap->begin(); i!= m_adder->m_ClassMap->end();i++) { + size_t siz = i->second->m_buffersize; + if ( m_buffer.first < siz ) { + m_buffer.second.reset(new unsigned char[m_buffer.first=siz]); } - memcpy(m_buffadd,i->second->m_buffer/*m_outservice->m_ser->buffer*/,siz); - SerialHeader *hd = (SerialHeader *)m_buffadd; + ::memcpy(m_buffer.second.get(),i->second->m_buffer,siz); + SerialHeader *hd = (SerialHeader *)m_buffer.second.get(); unsigned int runo = (unsigned int)hd->run_number; - if (m_currFile == 0) - { + if ( m_currFile == 0 ) { makeDirs(runo); openFile(); } - SavetoFile(m_buffadd); + savetoFile(m_buffer.second.get()); } closeFile(); -// m_Adder->Clear(); } } -void SaveTimer::Stop() +void SaveTimer::stop() { - GenTimer::Stop(); + this->GenTimer::stop(); } -void SaveTimer::setSaveSetService() +void SaveTimer::setSaveSetService(DimServerDns* dns) { - m_infoFileStatus = "SAVESETLOCATION/......................................................"; - std::string infoName = m_partname+"/"+m_taskname+"/SAVESETLOCATION"; - if (m_filenamesvc == 0) - { - m_filenamesvc = new DimService(infoName.c_str(),(char*)m_infoFileStatus.c_str()); + if ( !m_filenamesvc ) { + std::string infoName = m_partname+"/"+m_taskname+"/SAVESETLOCATION"; + m_filenamesvc.reset(new DimService(dns, infoName.c_str(),(char*)m_infoFileStatus.c_str())); } } -void SaveTimer::SavetoFile(void *buff) + +void SaveTimer::savetoFile(const void *buff) { - SerialHeader *hd = (SerialHeader *)buff; -// char fn[2*1024]; -// char fdir[1024]; + const SerialHeader *hd = (SerialHeader *)buff; void *bend = AddPtr(buff,hd->buffersize); unsigned int runo = (unsigned int)hd->run_number; static BRTLLock *loclock = 0; @@ -160,96 +109,37 @@ void SaveTimer::SavetoFile(void *buff) } buff = ((SerialHeader*)buff)->endPtr();//AddPtr(buff,sizeof(SerialHeader)); -#if 0 - fdir[0]=0; - fn[0]=0; - timeval ctim; - struct tm *tstruct; - const char* dir_name = m_rootdir.c_str(); - gettimeofday(&ctim,NULL); - tstruct = localtime(&ctim.tv_sec); - mkdir(dir_name,01777); - snprintf(fdir,sizeof(fdir),"%s/%4d",dir_name,tstruct->tm_year+1900); - mkdir(fdir,01777); - if (m_partname != "") - { - snprintf(fdir,sizeof(fdir),"%s/%s",dir_name,m_partname.c_str()); - mkdir(fdir,01777); - } - snprintf(fdir,sizeof(fdir),"%s/%s",dir_name,m_taskname.c_str()); - mkdir(fdir,01777); - snprintf(fdir,sizeof(fdir),"%s/%02d",dir_name,tstruct->tm_mon+1); - mkdir(fdir,01777); - snprintf(fdir,sizeof(fdir),"%s/%02d",dir_name,tstruct->tm_mday); - mkdir(fdir,01777); - if (!m_EOR) - { - sprintf(fn,"%s/%s-%d-%4d%02d%02dT%02d%02d%02d.root",fdir,m_taskname.c_str(),runo, - tstruct->tm_year+1900,tstruct->tm_mon+1,tstruct->tm_mday, - tstruct->tm_hour,tstruct->tm_min,tstruct->tm_sec); - } - else - { - sprintf(fn,"%s/%s-%u-%4d%02d%02dT%02d%02d%02d-EOR.root",fdir,m_taskname.c_str(),runo, - tstruct->tm_year+1900,tstruct->tm_mon+1,tstruct->tm_mday, - tstruct->tm_hour,tstruct->tm_min,tstruct->tm_sec); - } - - printf("File Saver: Filename %s\n",fn); - loclock->lockMutex(); - m_Adder->Lock(); - TFile *f = TFile::Open(fn,"RECREATE"); - m_Adder->UnLock(); - if (!f || f->IsZombie()) - { - printf("Root File %s cannot be opened or is Zombie\n",fn); - fflush (stdout); - loclock->unlockMutex(); - delete f; - return; - } -#endif TH1 *r; -// MonHist h; Bool_t dirstat = TH1::AddDirectoryStatus(); TH1::AddDirectory(kFALSE); DimBuffBase *prevb = 0; - while (buff <bend) - { + while (buff <bend) { DimBuffBase *b = (DimBuffBase*)buff; - if (b->reclen <= 0) - { + if (b->reclen <= 0) { printf("Bad Record. Record Length <=0!!! Previous record %p! \n",(void*)prevb); } - switch (b->type) - { + switch (b->type) { case H_1DIM: case H_2DIM: case H_3DIM: case H_PROFILE: case H_RATE: - case H_2DPROFILE: - { + case H_2DPROFILE: { dyn_string *hname; - m_Adder->Lock(); + m_adder->Lock(); r = (TH1*)(HistSerDes::de_serialize(buff)); - m_Adder->UnLock(); + m_adder->UnLock(); char hnam[4096]; hname = Strsplit(r->GetName(),"/"); - strcpy(hnam,r->GetName()); -// fprintf(((HistAdder*)m_Adder)->logFile,"==========>[Error] Saving histogram with name '%s'\n",hnam); + ::strcpy(hnam,r->GetName()); gDirectory->Cd("/"); - for (unsigned int i=0;i<hname->size()-1;i++) - { - TKey *k; - k = gDirectory->GetKey(hname->at(i).c_str()); - if (k == 0) - { + for (unsigned int i=0;i<hname->size()-1;i++) { + TKey *k = gDirectory->GetKey(hname->at(i).c_str()); + if (k == 0) { gDirectory->mkdir(hname->at(i).c_str()); } gDirectory->Cd(hname->at(i).c_str()); } -// r->SetName(ptok); switch(b->type) { case H_1DIM: @@ -259,17 +149,15 @@ void SaveTimer::SavetoFile(void *buff) case H_2DPROFILE: case H_RATE: { - m_Adder->Lock(); + m_adder->Lock(); r->Write(hname->at(hname->size()-1).c_str()); - m_Adder->UnLock(); + m_adder->UnLock(); break; } } - m_Adder->Lock(); + m_adder->Lock(); deletePtr(r); -// h.FreeDeser(); - m_Adder->UnLock(); -// r->Write(ptok); + m_adder->UnLock(); prevb = b; buff = AddPtr(buff,b->reclen); continue; @@ -286,17 +174,10 @@ void SaveTimer::SavetoFile(void *buff) } } } -// fflush(((HistAdder*)m_Adder)->logFile); TH1::AddDirectory(dirstat); -// m_Adder->Lock(); -// f->Close(); -// delete f; -// m_Adder->UnLock(); -// loclock->unlockMutex(); -// if (m_filenamesvc != 0) m_filenamesvc->updateService(fn); } -void SaveTimer::makeDirs(int runo) -{ + +void SaveTimer::makeDirs(int runo) { char fdir[1024]; char fn[2048]; char _root[256] = ""; @@ -309,75 +190,71 @@ void SaveTimer::makeDirs(int runo) fn[0] = 0; timeval ctim; struct tm *tstruct; - m_Adder->Lock(); - gettimeofday(&ctim, NULL); - tstruct = localtime(&ctim.tv_sec); + m_adder->Lock(); + ::gettimeofday(&ctim, NULL); + tstruct = ::localtime(&ctim.tv_sec); ::snprintf(_root, sizeof(_root), "%s", m_rootdir.c_str()); ::strncat(fdir, _root, sizeof(fdir) - 1); fdir[sizeof(fdir) - 1] = 0; - mkdir(fdir, 01777); + ::mkdir(fdir, 01777); ::snprintf(_year, sizeof(_year), "/%4d", tstruct->tm_year + 1900); ::strncat(fdir, _year, sizeof(fdir) - 1); fdir[sizeof(fdir) - 1] = 0; - mkdir(fdir, 01777); - if (m_partname != "") - { + ::mkdir(fdir, 01777); + if (m_partname != "") { ::snprintf(_part, sizeof(_part), "/%s", m_partname.c_str()); - strncat(fdir, _part, sizeof(fdir) - 1); + ::strncat(fdir, _part, sizeof(fdir) - 1); fdir[sizeof(fdir) - 1] = 0; - mkdir(fdir, 01777); + ::mkdir(fdir, 01777); } ::snprintf(_task, sizeof(_task), "/%s", m_taskname.c_str()); strncat(fdir, _task, sizeof(fdir) - 1); fdir[sizeof(fdir) - 1] = 0; - mkdir(fdir, 01777); + ::mkdir(fdir, 01777); ::snprintf(_month, sizeof(_month), "/%02d", tstruct->tm_mon + 1); - strncat(fdir, _month, sizeof(fdir) - 1); + ::strncat(fdir, _month, sizeof(fdir) - 1); fdir[sizeof(fdir) - 1] = 0; - mkdir(fdir, 01777); + ::mkdir(fdir, 01777); ::snprintf(_day, sizeof(_day), "/%02d", tstruct->tm_mday); - strncat(fdir, _day, sizeof(fdir) - 1); + ::strncat(fdir, _day, sizeof(fdir) - 1); fdir[sizeof(fdir) - 1] = 0; - mkdir(fdir, 01777); - if (!m_EOR) - { + ::mkdir(fdir, 01777); + if (!m_EOR) { ::snprintf(fn, sizeof(fn), "%s/%s-%d-%4d%02d%02dT%02d%02d%02d.root", fdir, - m_taskname.c_str(), runo, tstruct->tm_year + 1900, tstruct->tm_mon + 1, - tstruct->tm_mday, tstruct->tm_hour, tstruct->tm_min, tstruct->tm_sec); + m_taskname.c_str(), runo, tstruct->tm_year + 1900, tstruct->tm_mon + 1, + tstruct->tm_mday, tstruct->tm_hour, tstruct->tm_min, tstruct->tm_sec); } - else - { + else { ::snprintf(fn, sizeof(fn), "%s/%s-%d-%4d%02d%02dT%02d%02d%02d-EOR.root", - fdir, m_taskname.c_str(), runo, tstruct->tm_year + 1900, - tstruct->tm_mon + 1, tstruct->tm_mday, tstruct->tm_hour, - tstruct->tm_min, tstruct->tm_sec); + fdir, m_taskname.c_str(), runo, tstruct->tm_year + 1900, + tstruct->tm_mon + 1, tstruct->tm_mday, tstruct->tm_hour, + tstruct->tm_min, tstruct->tm_sec); } m_currFileName = fn; - m_Adder->UnLock(); + m_adder->UnLock(); } -void SaveTimer::openFile() -{ - m_Adder->Lock(); - m_currFile = TFile::Open(m_currFileName.c_str(), "RECREATE"); - m_Adder->UnLock(); - if (!m_currFile || m_currFile->IsZombie()) - { - printf("Root File %s cannot be opened or is Zombie\n", m_currFileName.c_str()); - fflush(stdout); - delete m_currFile; - m_currFile = 0; + +void SaveTimer::openFile() { + m_adder->Lock(); + m_currFile.reset(TFile::Open(m_currFileName.c_str(), "RECREATE")); + m_adder->UnLock(); + if ( !m_currFile ) { + printf("Root File %s cannot be opened\n", m_currFileName.c_str()); + } + else if ( m_currFile->IsZombie()) { + printf("Root File %s is Zombie\n", m_currFileName.c_str()); + m_currFile.reset(); } } -void SaveTimer::closeFile() -{ - m_Adder->Lock(); - m_currFile->Close(); - delete m_currFile; - m_currFile = 0; - m_Adder->UnLock(); - if (m_filenamesvc != 0) - { - // DimLock l; - m_filenamesvc->updateService((char*)m_currFileName.c_str()); + +void SaveTimer::closeFile() { + if ( m_currFile ) { + m_adder->Lock(); + m_currFile->Close(); + m_currFile.reset(); + m_adder->UnLock(); + if ( m_filenamesvc ) { + m_filenamesvc->updateService((char*)m_currFileName.c_str()); + } } } diff --git a/Online/GauchoAppl/src/components/BusySvc.cpp b/Online/GauchoAppl/src/components/BusySvc.cpp index ddda72ffed21baa07fd4894793597e20f854e41a..930609d079d9e2696d82fc473e486bb6be1301b2 100644 --- a/Online/GauchoAppl/src/components/BusySvc.cpp +++ b/Online/GauchoAppl/src/components/BusySvc.cpp @@ -113,7 +113,7 @@ StatusCode BusySvc::start() StatusCode sc; sc = Service::start(); m_bogus = m_Mybogus; - m_timer->Start(); + m_timer->start(); return StatusCode::SUCCESS; } diff --git a/Online/GauchoAppl/src/components/MemTrnd.cpp b/Online/GauchoAppl/src/components/MemTrnd.cpp index 13fb90abcf3c98283fb86b168efb9c1ee4a23039..74e20902af3f58a398e2b84ed49a495bfaf9f48a 100644 --- a/Online/GauchoAppl/src/components/MemTrnd.cpp +++ b/Online/GauchoAppl/src/components/MemTrnd.cpp @@ -46,7 +46,7 @@ StatusCode MemTrnd::initialize() m_trender->setMaxTimeNoWrite(600); } m_timer = new TrndTimer(m_trender,this,m_interv); - m_timer->Start(); + m_timer->start(); return StatusCode::SUCCESS; } @@ -65,7 +65,7 @@ StatusCode MemTrnd::stop() } StatusCode MemTrnd::finalize() { - m_timer->Stop(); + m_timer->stop(); std::string t1 = "VirtMem"; std::string t2 = "ResidentSize"; m_trender->addEntry(t1,double(0.0)); @@ -99,16 +99,12 @@ MemTrnd::~MemTrnd() { } -StatusCode MemTrnd::queryInterface(const InterfaceID& riid, void** ppvIF) -{ +StatusCode MemTrnd::queryInterface(const InterfaceID& riid, void** ppvIF) { if ( IIncidentListener::interfaceID().versionMatch(riid) ) - { *ppvIF = (IIncidentListener*)this; - } else - { return Service::queryInterface(riid, ppvIF); - } + addRef(); return StatusCode::SUCCESS; } @@ -119,6 +115,7 @@ TrndTimer::TrndTimer(ISimpleTrendWriter *trender,MemTrnd *mtrend,int period) : G m_MemTrnd = mtrend; m_lock.m_name = "TrendLock"; } + void TrndTimer::timerHandler() { long rss; @@ -132,9 +129,10 @@ void TrndTimer::timerHandler() m_trender->saveEvent(); m_lock.unlockMutex(); } -void TrndTimer::Stop() + +void TrndTimer::stop() { m_lock.lockMutex(); - GenTimer::Stop(); + this->GenTimer::stop(); m_lock.unlockMutex(); } diff --git a/Online/GauchoAppl/src/components/MemTrnd.h b/Online/GauchoAppl/src/components/MemTrnd.h index 129365b85395d8da4671631b93705fbe6c0bc4a3..f450dcbdd81186e1566070bdb3c20fa5dab60800 100644 --- a/Online/GauchoAppl/src/components/MemTrnd.h +++ b/Online/GauchoAppl/src/components/MemTrnd.h @@ -41,12 +41,12 @@ public: }; class TrndTimer : public GenTimer { + ISimpleTrendWriter* m_trender; + MemTrnd *m_MemTrnd; + BRTLLock m_lock; public: TrndTimer(ISimpleTrendWriter *trender,MemTrnd *mtrend,int period); void timerHandler ( void ) override; - BRTLLock m_lock; - void Stop(); - ISimpleTrendWriter* m_trender; - MemTrnd *m_MemTrnd; + void stop() override; }; #endif // ONLINE_GAUCHO_MEMTRND_H diff --git a/Online/GauchoAppl/src/components/PubSvc.cpp b/Online/GauchoAppl/src/components/PubSvc.cpp index de243777f30df93eed59e1b0c6fe127e31262a29..6a8b2ba829f249cce8ce33fd9f3f6c5aa11a4780 100644 --- a/Online/GauchoAppl/src/components/PubSvc.cpp +++ b/Online/GauchoAppl/src/components/PubSvc.cpp @@ -276,7 +276,7 @@ StatusCode PubSvc::finalize() // DimLock l; if (m_SaveTimer != 0) { - m_SaveTimer->Stop(); + m_SaveTimer->stop(); deletePtr(m_SaveTimer); } if (m_adder != 0) diff --git a/Online/GauchoBase/Gaucho/GenTimer.h b/Online/GauchoBase/Gaucho/GenTimer.h index dde8b9f5fb21dbc7375553eef7ae729d6bcbb854..efb8f92f900daefd0fb1b2368e93d9f25ba2930d 100644 --- a/Online/GauchoBase/Gaucho/GenTimer.h +++ b/Online/GauchoBase/Gaucho/GenTimer.h @@ -46,16 +46,12 @@ public: BRTLLock m_lock; bool m_dontdimlock; GenTimer(void *arg, int period = 10000,int typ=TIMER_TYPE_PERIODIC+TIMER_MODIFYER_SYNCHRONIZED); -// Period is in milli-seconds... + // Period is in milli-seconds... virtual ~GenTimer(void); - virtual void timerHandler ( void ) =0 ; - void Start(); - void Start(int period) - { - m_period = period*1000; - Start(); - } - void Stop(); + virtual void timerHandler ( void ) = 0; + virtual void start(); + virtual void startPeriodic(int period); + virtual void stop(); void setExtLastDelta(unsigned long *a){m_extlastdelta = a;return;}; unsigned long getDeltaTime(int incr=0); void *ThreadRoutine(); diff --git a/Online/GauchoBase/Gaucho/HistSerDes.h b/Online/GauchoBase/Gaucho/HistSerDes.h index a37c45e4b2b532ea3a136e678ca294fe8094a22c..facce8d30bf02bcabd907f4f69be94177f1fc210 100644 --- a/Online/GauchoBase/Gaucho/HistSerDes.h +++ b/Online/GauchoBase/Gaucho/HistSerDes.h @@ -14,7 +14,7 @@ class HistSerDes { public: - static void *de_serialize(void *ptr, char *nam=0); + static void *de_serialize(const void *ptr, char *nam=0); static void cpyBinLabels(char *,std::vector<std::string>&, int); static void SetBinLabels(TAxis *ax, char *l); static int GetBinLabels(TAxis *ax, std::vector<std::string>&); diff --git a/Online/GauchoBase/Gaucho/MonTimer.h b/Online/GauchoBase/Gaucho/MonTimer.h index 65ee8242ea0b4975b9416ba718c61f48cfcd4673..949456c4e7d5db6e32c5ec918750f8a07ba3cee2 100644 --- a/Online/GauchoBase/Gaucho/MonTimer.h +++ b/Online/GauchoBase/Gaucho/MonTimer.h @@ -23,6 +23,6 @@ public: MonTimer(MonitorClass *tis, int period = 10); virtual ~MonTimer(void); void timerHandler ( void ) override; - void Stop(); + void stop() override; }; #endif // ONLINE_GAUCHO_MONTIMER_H diff --git a/Online/GauchoBase/Gaucho/SerialHeader.h b/Online/GauchoBase/Gaucho/SerialHeader.h index 531e1de61c54a0ae954c6b7dbb39db5f7d2b0253..d844d146ebb65000fb83084b072991623910584f 100644 --- a/Online/GauchoBase/Gaucho/SerialHeader.h +++ b/Online/GauchoBase/Gaucho/SerialHeader.h @@ -19,6 +19,8 @@ #ifndef SERIALHEADER_H_ #define SERIALHEADER_H_ +#include <cstring> + #define SERHEADER_Compress 1<<0 #define SERHEADER_Version 2 #define SERIAL_MAGIC 0xfeedbabe diff --git a/Online/GauchoBase/Gaucho/TaskSaveTimer.h b/Online/GauchoBase/Gaucho/TaskSaveTimer.h index a09d1256fce5baeb851e82a1ed69b8e6ead24168..c4fbb86a9a4606e84635582d083c805d3a035ab6 100644 --- a/Online/GauchoBase/Gaucho/TaskSaveTimer.h +++ b/Online/GauchoBase/Gaucho/TaskSaveTimer.h @@ -15,7 +15,11 @@ #include "Gaucho/MonSubSys.h" #include "Gaucho/MonSys.h" typedef std::map<std::string,void*> HISTMAP; + + class TFile; +class DimService; + class TaskSaveTimer : public GenTimer { MonSubSys *m_subsys; @@ -27,25 +31,29 @@ class TaskSaveTimer : public GenTimer std::string m_rootdir; std::string m_partname; std::string m_taskname; - bool m_EOR; - MonSys *m_MonSys; std::string m_currDir; std::string m_currFileName; + bool m_EOR; + MonSys *m_MonSys; TFile *m_currFile; + + public: + DimService *m_filenamesvc; + public: TaskSaveTimer(MonSubSys *tis, int period = 900); ~TaskSaveTimer(void); void timerHandler ( void ) override; - void Stop(); - void SavetoFile(void *buff); + void stop() override; + void savetoFile(void *buff); void setRootDir(std::string &p){m_rootdir = p;return;}; void setPartName(std::string &p){ m_partname= p;return;}; void setTaskName(std::string &p){m_taskname = p;return;}; void setMonSys(MonSys *p){m_MonSys = p;return;}; void setEOR(bool flg){m_EOR = flg;return;}; + void setService(DimService* svc) { m_filenamesvc = svc; } void makeDirs(int runno); void openFile(); void closeFile(); - DimService *m_filenamesvc; }; #endif diff --git a/Online/GauchoBase/src/GenTimer.cpp b/Online/GauchoBase/src/GenTimer.cpp index d07bfa673bfc678a3be912305b36e31fc62e5bf2..b11bc457bf68bd1c848bad04440e96939132da48 100644 --- a/Online/GauchoBase/src/GenTimer.cpp +++ b/Online/GauchoBase/src/GenTimer.cpp @@ -28,10 +28,7 @@ namespace { - int ThreadRoutine_C(void* arg) - { -// int dum; -// pthread_setcanceltype(PTHREAD_CANCEL_ENABLE,&dum); + int ThreadRoutine_C(void* arg) { GenTimer *t = (GenTimer*)arg; t->ThreadRoutine(); t->m_threadpid =0; @@ -61,61 +58,45 @@ GenTimer::GenTimer(void *arg, int period, int typ) GenTimer::~GenTimer( ) { - Stop(); + this->stop(); } -//void GenTimer::timerHandler() -//{ -//} - -void GenTimer::Start() -{ - if ( m_thread == 0 ) - { +void GenTimer::start() { + if ( m_thread == 0 ) { m_ForceExit = false; this->m_stopSeen = false; -// int status = ::lib_rtl_start_thread(ThreadRoutine_C,this,&m_thread); m_thread = new std::thread(ThreadRoutine_C,this); m_ThreadBalance++; -// if ( !lib_rtl_is_success(status) ) -// { -// ::lib_rtl_output(LIB_RTL_ERROR,"Timer Thread NOT Started successfully %d\n", status); -// } } - else - { - if (!m_periodic) - { - Stop(); + else { + if (!m_periodic) { + stop(); m_ForceExit = false; m_thread = new std::thread(ThreadRoutine_C,this); m_ThreadBalance++; -// int status = ::lib_rtl_start_thread(ThreadRoutine_C,this,&m_thread); -// if ( !lib_rtl_is_success(status) ) -// { -// ::lib_rtl_output(LIB_RTL_ERROR,"Timer Thread NOT Started successfully %d\n", status); -// } } } } -void GenTimer::Stop() -{ -// m_lock.lockMutex(); - if (!this->m_dontdimlock) dim_lock(); - if (m_thread != 0) - { +void GenTimer::startPeriodic(int period) { + m_period = period*1000; + this->start(); +} + +void GenTimer::stop() { + if (!this->m_dontdimlock) + dim_lock(); + if (m_thread != 0) { m_stopSeen = false; m_ForceExit = true; int ncnt=0; - while (!m_stopSeen && ncnt <5) - { + while (!m_stopSeen && ncnt < 5) { m_ForceExit = true; usleep(10000); ncnt++; } m_thread->detach(); - deletePtr( m_thread); + deletePtr(m_thread); m_ThreadBalance--; } if (!this->m_dontdimlock) dim_unlock(); @@ -246,17 +227,6 @@ int GenTimer::NanoSleep(struct timespec *req, struct timespec *) { status = nanosleep(&req1,&req1); if (m_ForceExit) return -1; -// if (status == -1) -// { -// if (errno == EINTR) -// { -// continue; -// } -// } -// else -// { -// continue; -// } } return status; } diff --git a/Online/GauchoBase/src/MonHist.cpp b/Online/GauchoBase/src/MonHist.cpp index afe1f01b2d0cc89a467629a70de8008e82d15363..5a35c9d9642cfdd0a9d0b754dd2cd9956f9e71ad 100644 --- a/Online/GauchoBase/src/MonHist.cpp +++ b/Online/GauchoBase/src/MonHist.cpp @@ -15,21 +15,21 @@ * Created on: Mar 29, 2010 * Author: beat */ -#include "Gaucho/MonHist.h" -#include "TObject.h" -#include "Gaucho/RootHists.h" +#include <Gaucho/MonHist.h> +#include <TObject.h> +#include <Gaucho/RootHists.h> -#include "AIDA/IHistogram1D.h" -#include "AIDA/IHistogram2D.h" -#include "AIDA/IHistogram3D.h" -#include "AIDA/IProfile2D.h" -#include "AIDA/IProfile1D.h" +#include <AIDA/IHistogram1D.h> +#include <AIDA/IHistogram2D.h> +#include <AIDA/IHistogram3D.h> +#include <AIDA/IProfile2D.h> +#include <AIDA/IProfile1D.h> #include <GaudiUtils/Aida2ROOT.h> -#include "Gaucho/dimhist.h" -#include "Gaucho/CntrMgr.h" -#include "Gaucho/Utilities.h" -#include "RTL/rtl.h" -#include "Gaucho/HistSerDes.h" +#include <Gaucho/dimhist.h> +#include <Gaucho/CntrMgr.h> +#include <Gaucho/Utilities.h> +#include <RTL/rtl.h> +#include <Gaucho/HistSerDes.h> #include <stdexcept> using namespace std; @@ -80,212 +80,29 @@ void HistSerDes::SetBinLabels(TAxis *ax, char *labs) lab = (char*) AddPtr(lab, strlen(lab)+1); } } -#if 0 -template <typename T> void MonHist<T>::_clear() -{ - this->m_type = H_ILLEGAL; - m_rootobj = 0; - for (size_t i=0; i<m_Axes.size();i++) - { - m_Axes[i].m_labels.clear(); - m_Axes[i].m_lablen = -1; - } - m_Axes.clear(); -// m_rootdeser = 0; - m_cntrmgr = 0; - m_xmitbuffersize = sizeof(DimBuffBase); - m_hdrlen = 0; - buffersize = 0; - m_namelen = 0; - m_titlen = 0; - m_addoff = 0; - m_hentries = 0; - m_hsumw2 = 0; - m_hsumw = 0; - m_hbinsumw2 = 0; - m_blocksize = 0; - TH1D::SetDefaultSumw2(); - TH2D::SetDefaultSumw2(); - TProfile::SetDefaultSumw2(); -} -#endif template<typename T> MonHist<T>::MonHist() { _clear(); } -//template <typename T> MonHist<T>::MonHist(const string& source, const string &desc, T *hist) -#if 0 -template <typename T> MonHist<T>::MonHist(const string& source, const string &desc, const T &hist) -{ - m_name = source; - m_title = desc; - m_rootobj = const_cast<T*>(&hist); - m_cntrmgr = 0; - m_addoff = 0; - setup(); -} -#endif template <typename T> MonHist<T>::MonHist(const string& /* source */, const CntrMgr& /* cm */) { throw runtime_error("MonHist<T>::MonHist(const string&, CntrMgr*): Invalid constructor call!"); } -#if 0 -template<typename T> MonHist<T>::~MonHist() -{ - Bool_t dirstat = TH1::AddDirectoryStatus(); - TH1::AddDirectory (kFALSE); - for (size_t i=0; i<m_Axes.size();i++) - { - m_Axes[i].m_labels.clear(); - m_Axes[i].m_lablen = -1; - } - m_Axes.clear(); - m_rootobj = 0; - TH1::AddDirectory(dirstat); -} -#endif -//template <typename T> void MonHist<T>::clear() -//{ -// if (m_rootobj != 0) m_rootobj->Reset(); -//} -#if 0 -template<typename T> void MonHist<T>::makeCounters() -{ -} -template<typename T> void MonHist<T>::resetup(void) -{ - switch (m_type) - { - case H_1DIM: - case H_2DIM: - case H_PROFILE: - case H_3DIM: - case H_2DPROFILE: - { - for (size_t i=0; i<m_Axes.size();i++) - { - m_Axes[i].m_labels.clear(); - m_Axes[i].m_lablen = -1; - } - m_Axes.clear(); - setup (); - break; - } - case H_RATE: - case C_INT: - case C_LONGLONG: - case C_FLOAT: - case C_DOUBLE: - case C_STATENT: - case H_ILLEGAL: - case C_VOIDSTAR: - default: - break; - } -} -template<typename T> int MonHist<T>::xmitbuffersize() -{ - resetup(); - return m_xmitbuffersize; -} -#endif template<> void MonHist<StatEntityShadow>::clear() { if (m_rootobj != 0) m_rootobj->Reset(); -// this->Reset(); + // this->Reset(); } template<typename T> void MonHist<T>::clear() { if (m_rootobj != 0) m_rootobj->Reset("ICES"); } -#if 0 -template<typename T> void MonHist<T>::List() -{ - string typ; - switch (m_type) - { - case H_1DIM: - { - typ = "H_1DIM"; - break; - } - case H_2DIM: - { - typ = "H_2DIM"; - break; - } - case H_3DIM: - { - typ = "H_3DIM"; - break; - } - case H_PROFILE: - { - typ = "H_PROFILE"; - break; - } - case H_2DPROFILE: - { - typ = "H_2DPROFILE"; - break; - } - case H_RATE: - { - typ = "H_RATE"; - break; - } - default: - { - typ = "UNKNOWN"; - } - } -// printf("Histogram Type: %s Bins(%i,%i) Name: %s\n",typ.c_str(),m_nx, m_ny, name()); -} -template<> MonHist<MonRateProfile>::~MonHist() -{ - Bool_t dirstat = TH1::AddDirectoryStatus(); - TH1::AddDirectory (kFALSE); - for (size_t i=0; i<m_Axes.size();i++) - { - m_Axes[i].m_labels.clear(); - m_Axes[i].m_lablen = -1; - } - m_Axes.clear(); - if (m_rootobj != 0) delete m_rootobj; - m_rootobj = 0; - TH1::AddDirectory(dirstat); -} -#endif #include "HistSetups.inl.h" -#if 0 -template <> MonHist<StatEntityShadow>::MonHist(const string& source, const string &desc, const StatEntityShadow &se) -{ - _clear(); - m_name = source; - m_title = desc; - m_rootobj = const_cast<StatEntityShadow*>(&se); - m_cntrmgr = 0; - m_addoff = 0; - setup(); -} - -template<> MonHist<MonRateProfile>::MonHist(const string& source, const CntrMgr &cm) -{ - _clear(); - m_addoff = 9; - m_type = H_RATE; - m_name = source; - m_cntrmgr = const_cast<CntrMgr*>(&cm); - m_rootobj = 0; - m_xmitbuffersize = 0; -} -#endif - template<> void MonHist<MonRateProfile>::makeCounters() { Bool_t dirstat = TH1::AddDirectoryStatus(); @@ -316,9 +133,8 @@ template<> void MonHist<MonRateProfile>::makeCounters() tp->Fill(7.50, (double) (m_cntrmgr->deltaT()), 1.00); int i = 9; - CntrMgr::counterMapIt it; - for (it = m_cntrmgr->m_counterMap.begin(); - it != m_cntrmgr->m_counterMap.end(); it++) + auto& m = m_cntrmgr->m_counterMap; + for (auto it = m.begin(); it != m.end(); it++) { if (it->second.second.first == "int") { @@ -334,12 +150,12 @@ template<> void MonHist<MonRateProfile>::makeCounters() } else if (it->second.second.first.compare("StatEntityflag") == 0) { - StatEntityShadow* se = (StatEntityShadow*)it->second.second.second; + StatEntityShadow* se = (StatEntityShadow*)it->second.second.second; tp->Fill((double) i - 0.5, se->accumulatedFlag, 1.00); } else if (it->second.second.first.compare("StatEntitynEntries") == 0) { - StatEntityShadow* se = (StatEntityShadow*)it->second.second.second; + StatEntityShadow* se = (StatEntityShadow*)it->second.second.second; tp->Fill((double) i - 0.5, se->nEntries, 1.00); } else @@ -361,19 +177,11 @@ template<> void MonHist<MonRateProfile>::makeCounters() ax->SetBinLabel(8, "deltaT"); i = 9; - for (it = m_cntrmgr->m_counterMap.begin(); - it != m_cntrmgr->m_counterMap.end(); it++) - { - // msg <<MSG::DEBUG<<"label description: " << (*(it->second.first)).c_str() << endmsg; + for (auto it = m.begin(); it != m.end(); it++) { if (it->second.first.c_str() != 0) - { ax->SetBinLabel(i, it->second.first.c_str()); - } else - { ax->SetBinLabel(i, "Bad label"); - } - // printf("Rate Axis Label for bin %d %s\n",i, (*(it->second.first)).c_str()); i++; } } @@ -400,7 +208,7 @@ void HistSerDes::cpyBinLabels(char* dst, vector<string> &src, int ) return; } -void *HistSerDes::de_serialize(void *ptr, char *nam) +void *HistSerDes::de_serialize(const void *ptr, char *nam) { Bool_t dirstat = TH1::AddDirectoryStatus(); TH1::AddDirectory(kFALSE); @@ -412,24 +220,16 @@ void *HistSerDes::de_serialize(void *ptr, char *nam) { nam = (char*) AddPtr(p, p->nameoff); } -#include "signal.h" - char *utgid = getenv("UTGID"); - if (utgid == 0) - { - utgid = (char*)"unknown"; - } -// if (strstr(utgid,"RichDAQMon_00")!= 0) kill(getpid(),SIGSTOP); + const char *utgid = getenv("UTGID"); + if (utgid == 0) utgid = "unknown"; + switch (p->type) { case H_1DIM: case H_GAUDIH1D: { - DimHistbuff1 *b = (DimHistbuff1*) ptr; - char *tit = (char*) AddPtr(b, b->titoff); - if (strstr(utgid,"RichDAQMon_00")!= 0) - { -// ::lib_rtl_output(LIB_RTL_INFO,"De-Serializing H_1DIM %s\n",tit); - } + const DimHistbuff1 *b = (const DimHistbuff1*) ptr; + const char *tit = (const char*) AddPtr(b, b->titoff); titopt = tit; seppos = titopt.find(HistSerDes::optsep); if ((seppos != string::npos) && (seppos < 100000)) @@ -451,8 +251,8 @@ void *HistSerDes::de_serialize(void *ptr, char *nam) case H_2DIM: case H_GAUDIH2D: { - DimHistbuff2 *b = (DimHistbuff2*) ptr; - char *tit = (char*) AddPtr(b, b->titoff); + const DimHistbuff2 *b = (const DimHistbuff2*) ptr; + const char *tit = (const char*) AddPtr(b, b->titoff); if (strstr(utgid,"RichDAQMon_00")!= 0) { // ::lib_rtl_output(LIB_RTL_INFO,"De-Serializing H_2DIM %s\n",tit); @@ -485,12 +285,8 @@ void *HistSerDes::de_serialize(void *ptr, char *nam) case H_3DIM: case H_GAUDIH3D: { - DimHistbuff3 *b = (DimHistbuff3*) ptr; - char *tit = (char*) AddPtr(b, b->titoff); - if (strstr(utgid,"RichDAQMon_00")!= 0) - { -// ::lib_rtl_output(LIB_RTL_INFO,"De-Serializing H_3DIM %s\n",tit); - } + const DimHistbuff3 *b = (const DimHistbuff3*) ptr; + const char *tit = (const char*) AddPtr(b, b->titoff); titopt = tit; seppos = titopt.find(HistSerDes::optsep); if ((seppos != string::npos) && (seppos < 100000)) @@ -527,12 +323,8 @@ void *HistSerDes::de_serialize(void *ptr, char *nam) case H_RATE: case H_GAUDIPR1: { - DimHistbuff1 *b = (DimHistbuff1*) ptr; - char *tit = (char*) AddPtr(b, b->titoff); - if (strstr(utgid,"RichDAQMon_00")!= 0) - { -// ::lib_rtl_output(LIB_RTL_INFO,"De-Serializing H_PROFILE %s\n",tit); - } + const DimHistbuff1 *b = (const DimHistbuff1*) ptr; + const char *tit = (const char*) AddPtr(b, b->titoff); titopt = tit; seppos = titopt.find(HistSerDes::optsep); if ((seppos != string::npos) && (seppos < 100000)) @@ -540,17 +332,7 @@ void *HistSerDes::de_serialize(void *ptr, char *nam) bopt = titopt.substr(seppos + HistSerDes::optsep.length()); titopt.erase(seppos); } - if (strstr(utgid,"RichDAQMon_00")!= 0) - { -// ::lib_rtl_output(LIB_RTL_INFO,"New TProfile with: %s, %s,%d %f %f %s\n", -// nam,titopt.c_str(),b->nxbin,b->xmin, b->xmax, bopt.c_str()); - } MyTProfile *h = new MyTProfile(nam, titopt.c_str(),b->nxbin, b->xmin, b->xmax,bopt.c_str()); - if (strstr(utgid,"RichDAQMon_00")!= 0) - { -// ::lib_rtl_output(LIB_RTL_INFO,"New TProfile done with: %s, %s,%d %f %f %s\n", -// nam,titopt.c_str(),b->nxbin,b->xmin, b->xmax, bopt.c_str()); - } if (b->type != H_GAUDIPR1) { h->movefromdimbuffer(AddPtr(b, b->dataoff)); @@ -563,23 +345,15 @@ void *HistSerDes::de_serialize(void *ptr, char *nam) } else { -// bool sumw2flag=h->GetDefaultSumw2(); h->Sumw2(false); size_t nbin = b->nxbin+2; GaudiProfileBin *sers = (GaudiProfileBin*)AddPtr(b,b->dataoff); -// printf("DE-Serializing 1D Gaudi Profile %s:\n",nam); for (size_t i= 0;i<nbin;i++) { h->GetEntryArr()[i] = double(sers[i].nent); h->GetSumwArr()[i] = sers[i].sumw; h->GetSumw2Arr()[i] = sers[i].sumw2; } -// for (size_t i=0;i<nbin;i++) -// { -// printf ("%ld %f %f %f %f\n",i,h->GetEntryArr()[i],h->GetSumwArr()[i], h->GetSumw2Arr()[i], h->GetBinSumw2Arr()[i]); -// printf ("%ld %f %f %f\n",i,h->GetEntryArr()[i],h->GetSumwArr()[i], h->GetSumw2Arr()[i]); -// h->GetBinSumw2Arr()[i] = 1.0; -// } } h->SetEntries(b->nentries); h->fYmin = b->yminval; @@ -602,10 +376,6 @@ void *HistSerDes::de_serialize(void *ptr, char *nam) { DimHistbuff2 *b = (DimHistbuff2*) ptr; char *tit = (char*) AddPtr(b, b->titoff); - if (strstr(utgid,"RichDAQMon_00")!= 0) - { -// ::lib_rtl_output(LIB_RTL_INFO,"De-Serializing H_2DPROFILE %s\n",tit); - } titopt = tit; seppos = titopt.find(HistSerDes::optsep); if ((seppos != string::npos) && (seppos < 100000)) @@ -655,10 +425,6 @@ void *HistSerDes::de_serialize(void *ptr, char *nam) { DimHistbuff2 *b = (DimHistbuff3*) ptr; char *tit = (char*) AddPtr(b, b->titoff); - if (strstr(utgid,"RichDAQMon_00")!= 0) - { -// ::lib_rtl_output(LIB_RTL_INFO,"De-Serializing H_2DPROFILE %s\n",tit); - } titopt = tit; seppos = titopt.find(HistSerDes::optsep); if ((seppos != string::npos) && (seppos < 100000)) diff --git a/Online/GauchoBase/src/MonTimer.cpp b/Online/GauchoBase/src/MonTimer.cpp index ed88a1c170afde0e592dd1a76fb1c10f1b634e35..7f62033ab0f4b3a99a7a75db46ada9165c13ee19 100644 --- a/Online/GauchoBase/src/MonTimer.cpp +++ b/Online/GauchoBase/src/MonTimer.cpp @@ -66,7 +66,7 @@ void MonTimer::timerHandler ( void ) if (!m_dontdimlock) dim_unlock(); } -void MonTimer::Stop() +void MonTimer::stop() { - GenTimer::Stop(); + this->GenTimer::stop(); } diff --git a/Online/GauchoBase/src/MonitorClass.cpp b/Online/GauchoBase/src/MonitorClass.cpp index 7058bf99caa4b9ac887473983458a28ca9e17d13..88a03e3a1778a670f67ceecf29f1cf35c1bbdc97 100644 --- a/Online/GauchoBase/src/MonitorClass.cpp +++ b/Online/GauchoBase/src/MonitorClass.cpp @@ -162,11 +162,11 @@ void MonitorClass::setup(const char *n, bool expandnames, string &einfix) } void MonitorClass::start() { - if (m_Timer) m_Timer->Start(); + if (m_Timer) m_Timer->start(); } void MonitorClass::stop() { - if (m_Timer) m_Timer->Stop(); + if (m_Timer) m_Timer->stop(); } void MonitorClass::AddEntity(MonBase *c) diff --git a/Online/GauchoBase/src/MonitorInterface.cpp b/Online/GauchoBase/src/MonitorInterface.cpp index e57abd9c807aafb7d250634b89cd2688445495e0..b13cfed591173929303dbdd76a62a5ca7ea47278 100644 --- a/Online/GauchoBase/src/MonitorInterface.cpp +++ b/Online/GauchoBase/src/MonitorInterface.cpp @@ -313,12 +313,12 @@ void MonitorInterface::StartSaving(std::string &dir, std::string &part,std::stri m_savetimer->setPartName(part); m_savetimer->setRootDir(dir); m_savetimer->setTaskName(task); - m_savetimer->m_filenamesvc = sav; + m_savetimer->setService(sav); m_savetimer->setMonSys(m_MonSys); } - m_savetimer->Start(); + m_savetimer->start(); } void MonitorInterface::StopSaving() { - if ( m_savetimer ) m_savetimer->Stop(); + if ( m_savetimer ) m_savetimer->stop(); } diff --git a/Online/GauchoBase/src/TaskSaveTimer.cpp b/Online/GauchoBase/src/TaskSaveTimer.cpp index de75f5066e98f7c8a61f53434d2b70dd752a966d..0cf715cfb2929675683f0a71ad597105cac5ecd9 100644 --- a/Online/GauchoBase/src/TaskSaveTimer.cpp +++ b/Online/GauchoBase/src/TaskSaveTimer.cpp @@ -9,21 +9,22 @@ // Author : B.Jost // //========================================================================== -//#include "Gaucho/MonSubSys.h" -#include "Gaucho/ObjService.h" -#include "stdio.h" -#include "TFile.h" -#include "Gaucho/SerialHeader.h" -#include "Gaucho/MonHist.h" -#include "sys/time.h" -#include "sys/stat.h" -#include "sys/types.h" -#include "Gaucho/RootHists.h" -#include "Gaucho/Utilities.h" -#include "Gaucho/dimhist.h" -#include "Gaucho/TaskSaveTimer.h" -#include "Gaucho/MonitorClass.h" -#include "Gaucho/HistSerDes.h" + +#include <Gaucho/TaskSaveTimer.h> +//#include <Gaucho/ObjService.h> +#include <Gaucho/SerialHeader.h> +#include <Gaucho/MonHist.h> +#include <Gaucho/RootHists.h> +#include <Gaucho/Utilities.h> +#include <Gaucho/dimhist.h> +#include <Gaucho/MonitorClass.h> +#include <Gaucho/HistSerDes.h> + +#include <cstdio> +#include <TFile.h> +#include <sys/time.h> +#include <sys/stat.h> +#include <sys/types.h> TaskSaveTimer::TaskSaveTimer(MonSubSys *add, int period) : GenTimer((void*) add, period * 1000, TIMER_TYPE_PERIODIC) @@ -102,16 +103,16 @@ void TaskSaveTimer::timerHandler(void) m_bsiz = siz; } memcpy(m_buffadd,i->second->m_genSrv->m_ser->buffer,siz); - SavetoFile(m_buffadd); + savetoFile(m_buffadd); } closeFile(); m_subsys->Clear(); } } -void TaskSaveTimer::Stop() +void TaskSaveTimer::stop() { - GenTimer::Stop(); + this->GenTimer::stop(); } void TaskSaveTimer::makeDirs(int runo) { @@ -197,7 +198,7 @@ void TaskSaveTimer::closeFile() m_filenamesvc->updateService((char*)m_currFileName.c_str()); } } -void TaskSaveTimer::SavetoFile(void *buff) +void TaskSaveTimer::savetoFile(void *buff) { SerialHeader *hd = (SerialHeader *) buff; if (hd->m_magic != SERIAL_MAGIC) diff --git a/Online/GaudiOnline/components/InputAlg.cpp b/Online/GaudiOnline/components/InputAlg.cpp index 536fd210d9932b92ea7a78e8cee281c11201fbbe..a71599c79057720da4bea58638ea2e548a0df59b 100644 --- a/Online/GaudiOnline/components/InputAlg.cpp +++ b/Online/GaudiOnline/components/InputAlg.cpp @@ -136,16 +136,19 @@ StatusCode Online::InputAlg::process(EventContext const& /* ctxt */) const { } /// Now declare the event data if requested: if ( declare_banks || make_raw_evt ) { - evt_data_t event = this->create_event_data(e, 0); + auto event = this->create_event_data(e, 0); + if ( event.first != NO_MDF_ERROR ) { + return StatusCode::FAILURE; + } /// Invoke here the conversion to raw events if ( make_raw_evt ) { - const auto* pev = &event; + const auto* pev = &event.second; sc = m_evtTool->put("/Event/DAQ/RawEvent", *(const lb_banks_t*)pev); if ( !sc.isSuccess() ) { } } if ( declare_banks ) { - m_rawData.put(move(event)); + m_rawData.put(move(event.second)); } } /// Expand TAE data if requested and present diff --git a/Online/GaudiOnline/python/GaudiOnline/OnlineApplication.py b/Online/GaudiOnline/python/GaudiOnline/OnlineApplication.py index 8bf867bc825bd3a8542c9abe2e8bbd5eae30fa16..ca2881596f958255405b8946ff2bc3be1599e743 100644 --- a/Online/GaudiOnline/python/GaudiOnline/OnlineApplication.py +++ b/Online/GaudiOnline/python/GaudiOnline/OnlineApplication.py @@ -107,7 +107,7 @@ class Application(object): config.autoStart = False config.autoStop = False # Exec mode: 0 : synchronous; 1 : asynchronous 2 : synchronous pop(queue-length=1) - config.execMode = 2 + config.execMode = 0 config.monitorType = '' config.logDeviceType = 'RTL::Logger::LogDevice' config.logDeviceFormat = '%TIME%LEVEL%-8NODE: %-32PROCESS %-20SOURCE' @@ -116,9 +116,9 @@ class Application(object): config.maxConsecutiveErrors = 2 config.events_LowMark = 8000 config.events_HighMark = 18000 - config.numEventThreads = 2 + config.numEventThreads = 1 config.numStatusThreads = 1 - config.burstPrintCount = 1000 + config.burstPrintCount = 30000 ##config.numEventThreads = 1 # Debugging only ##config.events_LowMark = 50 ##config.events_HighMark = 180 @@ -143,20 +143,26 @@ class Application(object): self.input = input return self.input - def setup_monitoring(self, type='MonitorSvc'): + def setup_monitoring(self, task_name=None): config = self.config - config.monitorType = type mon = Configurables.MonitorSvc('MonitorSvc') mon.PartitionName = self.partitionName mon.ExpandNameInfix = '<proc>/' mon.ExpandCounterServices = True mon.UniqueServiceNames = True + mon.UseDStoreNames = True + mon.DimUpdateInterval = 5 + if task_name: + mon.ProgramName = task_name + self.app.ExtSvc.insert(0, mon) self.monSvc = mon update = Configurables.Online__UpdateAndReset('UpdateAndReset') update.resetOnStart = False; update.saverCycle = 900 update.saveHistograms = 0 + if task_name: + update.MyName = task_name self.updateAndReset = update; def setup_algorithms(self,*args,**kwd): @@ -170,10 +176,10 @@ class Application(object): config.MBM_partitionID = self.partitionID config.MBM_partitionName = self.partitionName config.MBM_partitionBuffers = partitionBuffers - config.MBM_numConnections = 4 - config.MBM_numEventThreads = 2 + config.MBM_numConnections = 1 + config.MBM_numEventThreads = 1 config.MBM_requests = [ - 'EvType=1;TriggerMask=0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF;VetoMask=0,0,0,0;MaskType=ANY;UserType=ONE;Frequency=PERC;Perc=100.0' + 'EvType=2;TriggerMask=0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF;VetoMask=0,0,0,0;MaskType=ANY;UserType=ONE;Frequency=PERC;Perc=100.0' ] return self @@ -182,7 +188,7 @@ class Application(object): config.inputType = 'NET' config.verifyBanks = True config.NET_requests = [ - 'EvType=1;TriggerMask=0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF;VetoMask=0,0,0,0;MaskType=ANY;UserType=ONE;Frequency=PERC;Perc=100.0' + 'EvType=2;TriggerMask=0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF;VetoMask=0,0,0,0;MaskType=ANY;UserType=ONE;Frequency=PERC;Perc=100.0' ] config.NET_source = source config.NET_eventTimeout = 10 @@ -204,7 +210,7 @@ class Application(object): config.FILE_mmapFiles = False config.FILE_sources = data_sources config.FILE_requests = [ - 'EvType=1;TriggerMask=0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF;VetoMask=0,0,0,0;MaskType=ANY;UserType=ONE;Frequency=PERC;Perc=100.0' + 'EvType=2;TriggerMask=0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF;VetoMask=0,0,0,0;MaskType=ANY;UserType=ONE;Frequency=PERC;Perc=100.0' ] return self @@ -224,7 +230,7 @@ class Application(object): config.FILE_mmapFiles = False config.FILE_sources = data_sources config.FILE_requests = [ - 'EvType=1;TriggerMask=0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF;VetoMask=0,0,0,0;MaskType=ANY;UserType=ONE;Frequency=PERC;Perc=100.0' + 'EvType=2;TriggerMask=0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF;VetoMask=0,0,0,0;MaskType=ANY;UserType=ONE;Frequency=PERC;Perc=100.0' ] return self diff --git a/Online/GaudiOnline/python/GaudiOnline/Passthrough.py b/Online/GaudiOnline/python/GaudiOnline/Passthrough.py index d6a1fd9bbd364db47778acf854938331bae3b2b8..0313b994bb1f35e8dc6efcf6e5cbea85613bb3e0 100644 --- a/Online/GaudiOnline/python/GaudiOnline/Passthrough.py +++ b/Online/GaudiOnline/python/GaudiOnline/Passthrough.py @@ -26,14 +26,16 @@ class Passthrough(Application): passThrough.AcceptRate = acceptRate self.passThrough = passThrough sequence = Gaudi.GaudiSequencer('Output') - sequence.Members = [passThrough] - if writer: sequence.Members.append(writer) - self.app.TopAlg = [] - self.app.TopAlg.append(input) - if hasattr(self,'updateAndReset'): - self.app.TopAlg.append(self.updateAndReset) - self.app.TopAlg.append(sequence) + sequence.Members = [self.input] + sequence.Members.append(self.updateAndReset) + sequence.Members.append(self.passThrough) + if isinstance(writer, (list, tuple)): + for item in writer: + sequence.Members.append(item) + elif writer: + sequence.Members.append(writer) self.sequence = sequence + + self.app.TopAlg = [self.sequence] self.broker.DataProducers = self.app.TopAlg return self - diff --git a/Online/GaudiOnlineTests/src/TestGbl.cpp b/Online/GaudiOnlineTests/src/TestGbl.cpp index dda6a256961749db9798346f65266d2b0e5cddbf..2282ed2bbd4da6f0279067f7fc2b4285d1292d92 100755 --- a/Online/GaudiOnlineTests/src/TestGbl.cpp +++ b/Online/GaudiOnlineTests/src/TestGbl.cpp @@ -11,7 +11,6 @@ //========================================================================== #include <fcntl.h> #include "RTL/rtl.h" -#include "RTL/Lock.h" #include "RTL/strdef.h" #include "RTL/GlobalSection.h" @@ -25,14 +24,14 @@ extern "C" int rtl_test_gbl(int argc, char** argv) { std::string name = txt; ::lib_rtl_unlink(("/dev/shm/sem."+name).c_str()); ::lib_rtl_unlink(("/dev/shm/"+name).c_str()); { - int status = RTL::Lock::create(name.c_str(), id); + int status = ::lib_rtl_create_lock(name.c_str(), &id); if ( lib_rtl_is_success(status) ) { RTL::GlobalSection gbl(name,512, true); if ( gbl ) { char* buff = gbl.buffer(); for( int i=0; i <turns; ++i ) { ::lib_rtl_sleep(msecs); - RTL::Lock lck(id); + ::lib_rtl_lock(id); if ( i != 0 ) { ::printf("%4d[%s] >> Read from shared memory: %s\n",i,proc.c_str(),buff); if ( strcmp(buff,txt) != 0 ) { @@ -44,10 +43,11 @@ extern "C" int rtl_test_gbl(int argc, char** argv) { { ::printf("%4d[%s] >> Wrote to shared memory: %s\n",i,proc.c_str(),buff); } + ::lib_rtl_unlock(id); } } + ::lib_rtl_delete_lock(id); } } - RTL::Lock::unlink(id); return 0; } diff --git a/Online/GaudiOnlineTests/src/TestSemaphore.cpp b/Online/GaudiOnlineTests/src/TestSemaphore.cpp index 6ededde69f2c16695dabc02351c22014c55a8cfc..58aa84c11fc0ba187ce817b617b44a352416e067 100755 --- a/Online/GaudiOnlineTests/src/TestSemaphore.cpp +++ b/Online/GaudiOnlineTests/src/TestSemaphore.cpp @@ -9,11 +9,9 @@ // Author : M.Frank // //========================================================================== -#include <cstdio> -#include "RTL/rtl.h" -#include "RTL/Lock.h" -#include "RTL/strdef.h" +/// Framework include files +#include <RTL/rtl.h> extern "C" int rtl_testSemaphoreSubProcess(int argc,const char* argv[]) { int msecs = 2000; @@ -22,13 +20,13 @@ extern "C" int rtl_testSemaphoreSubProcess(int argc,const char* argv[]) { std::string proc = argc>1 ? std::string(argv[1]) : RTL::processName(); std::string name = argc>2 ? std::string(argv[2]) : RTL::processName(); ::lib_rtl_unlink(("/dev/shm/sem."+name).c_str()); - int status = RTL::Lock::create(name.c_str(), id); + int status = ::lib_rtl_create_lock(name.c_str(), &id); if ( lib_rtl_is_success(status) ) { for( int i=0; i <turns; ++i ) { ::printf( "0x%08X >> Process %s waiting for lock %s....\n",i,proc.c_str(),name.c_str()); ::fflush(stdout); { - RTL::Lock lck(id); + ::lib_rtl_lock(id); ::printf("0x%08X >> Process %s holds lock %s for %d milliseconds....\n", i,proc.c_str(),name.c_str(),msecs); ::fflush(stdout); @@ -40,10 +38,11 @@ extern "C" int rtl_testSemaphoreSubProcess(int argc,const char* argv[]) { proc.c_str(),turns+1); } ::fflush(stdout); + ::lib_rtl_unlock(id); } lib_rtl_sleep(msecs); } - RTL::Lock::unlink(id); + ::lib_rtl_delete_lock(id); } return 0; } diff --git a/Online/GaudiOnlineTests/src/TestStdoutBuffering.cpp b/Online/GaudiOnlineTests/src/TestStdoutBuffering.cpp index aec50bc67d46870a64c39f04b811ff2216335255..6f6d1ece87cf77e2180950c6f3d6882cd1d0fe8b 100644 --- a/Online/GaudiOnlineTests/src/TestStdoutBuffering.cpp +++ b/Online/GaudiOnlineTests/src/TestStdoutBuffering.cpp @@ -9,11 +9,7 @@ // Author : M.Frank // //========================================================================== -#include <fcntl.h> #include "RTL/rtl.h" -#include "RTL/Lock.h" -#include "RTL/strdef.h" -#include "RTL/GlobalSection.h" static void help() { } diff --git a/Online/HTTP/HTTP/HttpHeader.h b/Online/HTTP/HTTP/HttpHeader.h index 622f0eef35c073acef5fc63f70e7c41e7e85a33d..09dcf609d5a5d573a2857ba665489cba6f451d25 100644 --- a/Online/HTTP/HTTP/HttpHeader.h +++ b/Online/HTTP/HTTP/HttpHeader.h @@ -31,6 +31,7 @@ namespace http { class constants { public: static constexpr const char* DATE_TIME_FORMAT = "%Y-%m-%d %H:%M:%S"; + static constexpr const char* direct = "Direct"; static constexpr const char* location = "Location"; static constexpr const char* date = "Date"; static constexpr const char* error_cause = "Error-Cause"; diff --git a/Online/IPMI/CMakeLists.txt b/Online/IPMI/CMakeLists.txt index a62b1e4158dbbc51685ebdf367b8753e5a9b5115..1dae2fe0dc62533e48a2296cb9d09e5e3e6051d8 100644 --- a/Online/IPMI/CMakeLists.txt +++ b/Online/IPMI/CMakeLists.txt @@ -20,3 +20,4 @@ endmacro() #Applexe(Test1 src/Applications/Test1.cpp) Applexe(ipmiSrv src/Applications/ipmiSrv.cpp) +Applexe(LanPtest src/Applications/LanPtest.cpp) diff --git a/Online/IPMI/src/Applications/LanPtest.cpp b/Online/IPMI/src/Applications/LanPtest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..32ade05da1b378a0e187907885bb629749c9a1aa --- /dev/null +++ b/Online/IPMI/src/Applications/LanPtest.cpp @@ -0,0 +1,372 @@ +//========================================================================== +// LHCb Online software suite +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see OnlineSys/LICENSE. +// +// Author : B.Jost +// +//========================================================================== +#include <string> +#include <thread> +#include <mutex> +#include <vector> +#include "string.h" +#include "stdio.h" +#include "unistd.h" +#include "stdlib.h" +#include "ctype.h" +#include "dim/dis.hxx" +#include "src/NewLib/NodeThread.h" +#include "src/NewLib/log.h" +//#include "src/NewLib/GlobalVars.h" +extern char *MyUTGID; +using namespace std; +std::string myUTGID; +class lan; +class LANPlus; +int verbose; +vector<string> StrSplit(string &s, char* tok) +{ + vector<string> ret; + string ss = s; + size_t tk = ss.find(tok); + while(tk!=string::npos) + { + ret.push_back(ss.substr(0,tk)); + ss=ss.substr(tk+1,string::npos); + tk = ss.find(tok); + } + ret.push_back(ss); + return ret; +} +void ToLower(string &s) +{ + for (size_t i=0;i<s.size();i++) + { + s[i]=tolower(s[i]); + } +} +void ToUpper(string &s) +{ + for (size_t i=0;i<s.size();i++) + { + s[i]=toupper(s[i]); + } +} +class NodeListElement : public NodeConfiguration +{ + public: + NodeListElement(string &N, string &U, string &P, string *sp, + int statepoll=1, int setuppoll=10):NodeConfiguration(N,U,P,sp,"LANPLUS",statepoll,setuppoll) + { + m_thread = 0; + }; + NodeListElement():NodeConfiguration() + { + m_thread = 0; + }; + thread *m_thread; +}; +void FarmSetup(char * farms, vector<NodeListElement*> &nodelist, NodeListElement &templ) +{ + size_t k; + char r; + char nodn[256]; + for (k = 0; k < strlen(farms); k++) + { + r = farms[k]; + switch (r) + { + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + { + for (int j = 1; j <= 10; j++) + { + for (int i = 1; i <= 28; i++) + { + sprintf(nodn, "hlt%c%02d%02d-IPMI", r, j, i); +// nodes.push_back(string(nodn)); + string nn = nodn; + ToUpper(nn); + nodelist.push_back(new NodeListElement(nn,templ.UserName,templ.Password,templ.ServicePrefix)); +// threads.push_back(new thread(NodeThread, new NodeConfiguration(nn,uname,pword,ServicePrefix) +// ,setup_fail,setup_fail_mtx)); + } + } + break; + } + case 'f': + { + for (int j = 1; j <= 12; j++) + { + int nods = 32;int fPrintf(const char *format, ...); + if (j == 7) + nods = 28; + for (int i = 1; i <= nods; i++) + { + sprintf(nodn, "hltf%02d%02d-IPMI", j, i); + string nn = nodn; + ToUpper(nn); +// nodes.push_back(string(nodn)); + nodelist.push_back(new NodeListElement(nn,templ.UserName,templ.Password,templ.ServicePrefix)); +// threads.push_back(new thread(NodeThread, new NodeConfiguration(nn,uname,pword,ServicePrefix) +// ,setup_fail,setup_fail_mtx)); + } + } + } + } + } + +} +size_t fnd; +void ParseConfigFile(char *supFile,vector<NodeListElement*> &nodelist, NodeListElement &templ) +{ + FILE * f; + char lin[2048]; + f=fopen(supFile,"r"); + string line; + line.reserve(2048); +// char *stat; + if (f == 0) return; + fgets(lin,2048,f); + while (!feof(f)) + { + line = lin; + line = line.substr(0,line.find("\n")); + fnd = line.find("#"); + + line = line.substr(0,fnd); + if (line.size() == 0) + { + line.reserve(2048); + fgets(lin,2048,f); + continue; + } + vector<string> splt = StrSplit(line,(char*)"="); + if (splt.size()>1) + { + if (splt[0].find("IPMI_USER")!=string::npos) + { + string opt = splt[1]; + size_t blk; + blk=opt.find(" "); + while (blk != string::npos) + { + opt.replace(blk,1,""); + blk=opt.find(" "); + } + templ.UserName = opt; + } + else if (splt[0].find("IPMI_PASSWD")!=string::npos) + { + string opt = splt[1]; + size_t blk; + blk=opt.find(" "); + while (blk != string::npos) + { + opt.replace(blk,1,""); + blk=opt.find(" "); + } + templ.Password = opt; + } + else if (splt[0].find("IPMI_CMD")!=string::npos) + { + Printf("Option IPMI_CMD ignored"); + } + else + { + Printf("Illegal Option %s",line.c_str()); + } + line.reserve(2048); + fgets(lin,2048,f); + continue; + } + else + { +//hostName,userName,passWord,port,authType,privLvl,oemType + vector<string> splt = StrSplit(line,(char*)","); + string nn=""; + NodeListElement *el; + if (splt.size()>0) + { + el = new NodeListElement(nn,templ.UserName,templ.Password,templ.ServicePrefix); + } + else + { + line.reserve(2048); + fgets(lin,2048,f); + continue; + } + for (size_t i=0;i<splt.size();i++) + { + switch(i) + { + case 0: + { + string nname = splt[i]; + ToUpper(nname); + el->NodeName = nname; + break; + } + case 1: + { + if (splt[i].find("NULL") == string::npos) + { + el->UserName = splt[i]; + } + break; + } + case 2: + { + if (splt[i].find("NULL") == string::npos) + { + el->Password = splt[i]; + } + break; + } + case 3: + { + if (splt[i].find("NULL") == string::npos) + { + Printf("Port Option in Node definition ignored\n"); + } + break; + } + case 4: + { + if (splt[i].find("NULL") == string::npos) + { + Printf("authType Option in Node definition ignored\n"); + } + break; + } + case 5: + { + if (splt[i].find("NULL") == string::npos) + { + Printf("privLvl Option in Node definition ignored\n"); + } + break; + } + case 6: + { + if (splt[i].find("NULL") == string::npos) + { + Printf("oemType Option in Node definition ignored\n"); + } + break; + } + default: + { + Printf("Too many items in node definition. Subsequent items ignored\n"); + break; + } + } + } + nodelist.push_back(el); + } + line.reserve(2048); + fgets(lin,2048,f); + } + fclose(f); +} + +int main(int argc, char **) +{ +#define OPTIONS "r:c:d:s:n:p:l" +// int status; + string *ServerName = new string("MyIPMIServer"); + string *ServicePrefix = new string("MyIPMIServer"); + string *setup_fail=new string(""); + string stat_fail; + mutex *setup_fail_mtx = new mutex;; + vector<string> nodes; + vector<thread*> threads; + string uname("lhcbadmin"); + string pword("lhcbipmi"); + string pfix("aaa"); +// string nnod1("hlta0101"); +// string nnod2("hlta0906"); + string nname("hlt20201-ipmi"); + NodeConfiguration nconf(nname,uname,pword,&pfix,"LANPLUS",1,10); + vector<NodeListElement*> nodelist; + if (argc == 1) + { + Printf("Usage: ipmiSrv <options>\n"); + Printf("Options:\n"); + Printf("\t-r <Farm Rows> e.g. abc\n"); + Printf("\t-c <configuration filipmiSrv2e>\n"); + Printf("\t-d <Polling delay in seconds>\n"); + Printf("\t-s <Setup retry delay> \n"); + Printf("\t-n <Dim Server Name>\n"); + Printf("\t-p <Dim Node Service Prefix>\n"); + Printf("\nNote: options -r and -c are mutually exclusive\n"); + return 0; + } + char *farms=0; + char *supFile=0; + log_init(0,0,0); + char *utg = getenv("UTGID"); + if (utg == 0) + { + pid_t pid=getpid(); + myUTGID = "p_"+to_string(pid); + } + else + { + myUTGID = utg; + } + MyUTGID = (char*)myUTGID.c_str(); + DimServer::autoStartOn(); + DimServer::start((char*)ServerName->c_str()); +//#if 0 +//#endif +// thread t1 = thread(NodeThread,nnod1); +// thread t2 = thread(NodeThread,nnod2); +// new thread(NodeThread,"hltd0112"); +// new thread(NodeThread,"hlte0602"); +// new thread(NodeThread,"hlte0603"); +// new thread(NodeThread,"hltd0922"); + string oldstr; + string failsvcname = *ServerName; + failsvcname +="/SetupFaileds"; + string nn=""; + NodeListElement NodeTemplate(nn,uname,pword,ServicePrefix); + if (farms) + { + FarmSetup(farms,nodelist,NodeTemplate); + } + else if (supFile) + { + ParseConfigFile(supFile,nodelist,NodeTemplate); + } +// for (size_t ii=0;ii<nodelist.size();ii++) +// { +// Printf ("%s\n",nodelist[ii]->NodeName.c_str()); +// } + DimService servc(failsvcname.c_str(),"C",(char*)setup_fail->c_str(),1); + +#define IF_lan 1 +#define IF_lanplus 2 + new thread(NodeThread<LANPlus>,&nconf,setup_fail,setup_fail_mtx); + while (1) + { +// sleep(0xffffffff); + sleep(2); + setup_fail_mtx->lock(); + if (oldstr != *setup_fail) + { + servc.updateService((char*)setup_fail->c_str(),setup_fail->size()); +// Printf("===> Setup Failing Nodes: %s\n",setup_fail->c_str()); + oldstr=*setup_fail; + } + setup_fail_mtx->unlock(); + } + return 0; +} diff --git a/Online/IPMI/src/Applications/ipmiSrv.cpp b/Online/IPMI/src/Applications/ipmiSrv.cpp index 2f71d54b1da74040a700676233140db7889b13e0..ef79d46d3d83991162841a87e20dcbbb68a244bc 100644 --- a/Online/IPMI/src/Applications/ipmiSrv.cpp +++ b/Online/IPMI/src/Applications/ipmiSrv.cpp @@ -25,6 +25,9 @@ extern char *MyUTGID; using namespace std; std::string myUTGID; +class lan; +class LANPlus; +int verbose; vector<string> StrSplit(string &s, char* tok) { vector<string> ret; @@ -56,8 +59,8 @@ void ToUpper(string &s) class NodeListElement : public NodeConfiguration { public: - NodeListElement(string &N, string &U, string &P, string *sp, - int statepoll=1, int setuppoll=10):NodeConfiguration(N,U,P,sp,statepoll,setuppoll) + NodeListElement(string &N, string &U, string &P, string *sp,string &IF, + int statepoll=1, int setuppoll=10):NodeConfiguration(N,U,P,sp,IF,statepoll,setuppoll) { m_thread = 0; }; @@ -67,6 +70,7 @@ class NodeListElement : public NodeConfiguration }; thread *m_thread; }; +#if 0 void FarmSetup(char * farms, vector<NodeListElement*> &nodelist, NodeListElement &templ) { size_t k; @@ -121,6 +125,7 @@ void FarmSetup(char * farms, vector<NodeListElement*> &nodelist, NodeListElement } } +#endif size_t fnd; void ParseConfigFile(char *supFile,vector<NodeListElement*> &nodelist, NodeListElement &templ) { @@ -172,6 +177,31 @@ void ParseConfigFile(char *supFile,vector<NodeListElement*> &nodelist, NodeListE } templ.Password = opt; } + else if (splt[0].find("IPMI_INTERFACE")!=string::npos) + { + string opt = splt[1]; + size_t blk; + blk=opt.find(" "); + while (blk != string::npos) + { + opt.replace(blk,1,""); + blk=opt.find(" "); + } + ToUpper(opt); + templ.Interface = opt; + } + else if (splt[0].find("IPMI_CIPHER")!=string::npos) + { + string opt = splt[1]; + size_t blk; + blk=opt.find(" "); + while (blk != string::npos) + { + opt.replace(blk,1,""); + blk=opt.find(" "); + } + templ.cipher = atoi(opt.c_str()); + } else if (splt[0].find("IPMI_CMD")!=string::npos) { Printf("Option IPMI_CMD ignored"); @@ -192,7 +222,7 @@ void ParseConfigFile(char *supFile,vector<NodeListElement*> &nodelist, NodeListE NodeListElement *el; if (splt.size()>0) { - el = new NodeListElement(nn,templ.UserName,templ.Password,templ.ServicePrefix); + el = new NodeListElement(nn,templ.UserName,templ.Password,templ.ServicePrefix,templ.Interface); } else { @@ -207,8 +237,41 @@ void ParseConfigFile(char *supFile,vector<NodeListElement*> &nodelist, NodeListE case 0: { string nname = splt[i]; - ToUpper(nname); - el->NodeName = nname; +// ToUpper(nname); + *el = templ; + vector<string> nsplt = StrSplit(nname,(char*)"/"); + switch(nsplt.size()) + { + case 1: + { + ToUpper(nsplt[0]); + el->NodeName = nsplt[0]; + break; + } + case 2: + { + ToUpper(nsplt[0]); + el->NodeName = nsplt[0]; + el->Interface = nsplt[1]; + break; + } + case 3: + { + ToUpper(nsplt[0]); + el->NodeName = nsplt[0]; + el->Interface = nsplt[1]; + el->cipher = atoi(nsplt[2].c_str()); + break; + } + case 0: + { + break; + } + default: + { + break; + } + } break; } case 1: @@ -386,23 +449,32 @@ int main(int argc, char **argv) string failsvcname = *ServerName; failsvcname +="/SetupFaileds"; string nn=""; - NodeListElement NodeTemplate(nn,uname,pword,ServicePrefix); - if (farms) - { - FarmSetup(farms,nodelist,NodeTemplate); - } - else if (supFile) - { - ParseConfigFile(supFile,nodelist,NodeTemplate); - } + string ln = ""; + NodeListElement NodeTemplate(nn,uname,pword,ServicePrefix,ln); + ParseConfigFile(supFile,nodelist,NodeTemplate); // for (size_t ii=0;ii<nodelist.size();ii++) // { // Printf ("%s\n",nodelist[ii]->NodeName.c_str()); // } DimService servc(failsvcname.c_str(),"C",(char*)setup_fail->c_str(),1); + +#define IF_lan 1 +#define IF_lanplus 2 +// int IFdialect; for (size_t i=0;i<nodelist.size();i++) { - nodelist[i]->m_thread = new thread(NodeThread,nodelist[i],setup_fail,setup_fail_mtx); + if (nodelist[i]->Interface == "LANPLUS") + { + nodelist[i]->m_thread = new thread(NodeThread<LANPlus>,nodelist[i],setup_fail,setup_fail_mtx); + } + else if (nodelist[i]->Interface == "LAN") + { + nodelist[i]->m_thread = new thread(NodeThread<lan>,nodelist[i],setup_fail,setup_fail_mtx); + } + else + { + nodelist[i]->m_thread = new thread(NodeThread<lan>,nodelist[i],setup_fail,setup_fail_mtx); + } } while (1) { diff --git a/Online/IPMI/src/NewLib/IPMINode.cpp b/Online/IPMI/src/NewLib/IPMINode.cpp index 0bbdafe6b73c94df723fef4a54487106d927eade..d1f23fef5e08c88304d8011094e26e8f02711624 100644 --- a/Online/IPMI/src/NewLib/IPMINode.cpp +++ b/Online/IPMI/src/NewLib/IPMINode.cpp @@ -17,11 +17,12 @@ #include "ipmi_chassis.h" #include "ipmi_session.h" #include "ipmi_constants.h" +using namespace std; //static struct ipmi_cmd ipmitool_cmd_list[] = { // { ipmi_chassis_main, "chassis", "Get chassis status and set power state" }, // { NULL ,"",""}, //}; -IPMINode::IPMINode(string &nname, string &uname, string &passw) : +template <class T> IPMINode<T>::IPMINode(string &nname, string &uname, string &passw) : m_Name(nname), m_username(uname), m_password(passw) { m_intName = m_Name;// + "-ipmi"; @@ -35,11 +36,11 @@ IPMINode::IPMINode(string &nname, string &uname, string &passw) : m_lastread = 0; m_retintf = 0; } -IPMINode::~IPMINode() +template <class T> IPMINode<T>::~IPMINode() { shutdown(); } -int IPMINode::shutdown() +template <class T> int IPMINode<T>::shutdown() { // if (m_state == inited) // { @@ -78,7 +79,7 @@ int IPMINode::shutdown() } return 0; } -int IPMINode::turnOn() +template <class T> int IPMINode<T>::turnOn() { if (m_state != inited) return 1; @@ -89,7 +90,7 @@ int IPMINode::turnOn() // int rc=ipmi_light_do_it(m_ipmiInterface,argc,argv); return rc; } -int IPMINode::turnOff() +template <class T> int IPMINode<T>::turnOff() { if (m_state != inited) return 1; @@ -100,7 +101,7 @@ int IPMINode::turnOff() // int rc=ipmi_light_do_it(m_ipmiInterface,argc,argv); return rc; } -int IPMINode::softOff() +template <class T> int IPMINode<T>::softOff() { if (m_state != inited) return 1; @@ -111,7 +112,7 @@ int IPMINode::softOff() // int rc=ipmi_light_do_it(m_ipmiInterface,argc,argv); return rc; } -int IPMINode::cycle() +template <class T> int IPMINode<T>::cycle() { if (m_state != inited) return 1; @@ -122,7 +123,7 @@ int IPMINode::cycle() // int rc=ipmi_light_do_it(m_ipmiInterface,argc,argv); return rc; } -int IPMINode::reset() +template <class T> int IPMINode<T>::reset() { if (m_state != inited) return 1; @@ -133,7 +134,7 @@ int IPMINode::reset() // int rc=ipmi_light_do_it(m_ipmiInterface,argc,argv); return rc; } -int IPMINode::getPowerState() +template <class T> int IPMINode<T>::getPowerState() { int statcnt; statcnt = 0; @@ -175,7 +176,7 @@ int IPMINode::getPowerState() m_lastUpdate->updateService(m_lastread); return rc; } -int IPMINode::setup(char * DimServerName) +template <class T> int IPMINode<T>::setup(char * DimServerName,NodeConfiguration &conf) { int rc=-1; @@ -194,21 +195,22 @@ int IPMINode::setup(char * DimServerName) uint8_t my_long_packet_set = 0; #endif uint8_t lookupbit = 0x10; /* use name-only lookup by default */ - + string lantyp=typeid(T).name(); + lantyp =lantyp.substr(1); if (m_state != uninited) { Printf("shit\n"); } if (m_ipmiInterface == 0) { - m_ipmiInterface = new ipmi_intf(); //*ipmi_main_intf,*IntfPatt; + m_ipmiInterface = new ipmi_intf<T>(); //*ipmi_main_intf,*IntfPatt; /* if no interface was specified but a * hostname was then use LAN by default * otherwise the default is hardcoded * to use the first entry in the list */ - m_ipmiInterface->ipmi_intf_load((char*) "lan"); + m_ipmiInterface->ipmi_intf_load((char*) lantyp.c_str()); } else { @@ -255,7 +257,10 @@ int IPMINode::setup(char * DimServerName) m_ipmiInterface->ipmi_intf_session_set_lookupbit(lookupbit); m_ipmiInterface->ipmi_intf_session_set_sol_escape_char( (char) SOL_ESCAPE_CHARACTER_DEFAULT); - m_ipmiInterface->ipmi_intf_session_set_cipher_suite_id(3); + if (lantyp=="LANPlus") + { + m_ipmiInterface->ipmi_intf_session_set_cipher_suite_id(conf.cipher); + } m_ipmiInterface->devnum = 0; @@ -266,7 +271,7 @@ int IPMINode::setup(char * DimServerName) m_ipmiInterface->my_addr = arg_addr ? arg_addr : IPMI_BMC_SLAVE_ADDR; if (m_ipmiInterface->opened == 0) { - if (m_ipmiInterface->open() < 0) + if (m_ipmiInterface->ipmi_open() < 0) { // ipmi_light_Cleanup(ipmi_main_intf); return 1; @@ -398,3 +403,7 @@ int IPMINode::setup(char * DimServerName) } return rc; } +#include "lan.h" +#include "LANPlus.h" +template class IPMINode<lan>; +template class IPMINode<LANPlus>; diff --git a/Online/IPMI/src/NewLib/IPMINode.h b/Online/IPMI/src/NewLib/IPMINode.h index 74de508531740d64d95ba7827af49959a41355be..0ed58c2cab7056dc759ee1c3057553de46478b2e 100644 --- a/Online/IPMI/src/NewLib/IPMINode.h +++ b/Online/IPMI/src/NewLib/IPMINode.h @@ -13,6 +13,7 @@ #define IPMISRV_H #include <string> using namespace std; +#include "NodeConfiguration.h" // #include "ipmilight.h" enum IPMIState { @@ -29,8 +30,8 @@ enum PowerState }; class DimService; class DimCommand; -class ipmi_intf; -class IPMINode +template <class T> class ipmi_intf; +template <class T> class IPMINode { public: #include "newnew.h" @@ -38,8 +39,8 @@ class IPMINode string m_intName; string m_username; string m_password; - ipmi_intf *m_ipmiInterface; - ipmi_intf *m_retintf; + ipmi_intf<T> *m_ipmiInterface; + ipmi_intf<T> *m_retintf; IPMINode (string &nname,string &uname,string &passw); ~IPMINode(); IPMIState m_state; @@ -57,7 +58,7 @@ class IPMINode int reset(); int softOff(); int getPowerState(); - int setup(char *DimserverName); + int setup(char *DimserverName, NodeConfiguration &conf); int shutdown(); }; #endif diff --git a/Online/IPMI/src/NewLib/LANBase.h b/Online/IPMI/src/NewLib/LANBase.h new file mode 100644 index 0000000000000000000000000000000000000000..65383369f25f9519c964aa19c8946b371c07eef7 --- /dev/null +++ b/Online/IPMI/src/NewLib/LANBase.h @@ -0,0 +1,61 @@ +/* + * LANBase.h + * + * Created on: Jul 16, 2021 + * Author: beat + */ + +#ifndef ONLINE_IPMI_SRC_NEWLIB_LANBASE_H_ +#define ONLINE_IPMI_SRC_NEWLIB_LANBASE_H_ +struct ipmi_rs; +struct ipmi_intf; +struct LANBase +{ + virtual ~LANBase(); + virtual int open(struct ipmi_intf *intf); + virtual int setup(struct ipmi_intf * intf)=0; + virtual int keepalive(struct ipmi_intf * intf)=0; + virtual int send_packet(struct ipmi_intf * intf, uint8_t * data, int data_len)=0; + virtual struct ipmi_rs * recv_packet(struct ipmi_intf * intf)=0; + virtual struct ipmi_rs * poll_recv(struct ipmi_intf * intf)=0; + virtual struct ipmi_rs * send_ipmi_cmd(struct ipmi_intf * intf, struct ipmi_rq * req)=0; + virtual struct ipmi_rs * send_payload(struct ipmi_intf * intf, + struct ipmi_v2_payload * payload)=0; + virtual void getIpmiPayloadWireRep( + struct ipmi_intf * intf, + struct ipmi_v2_payload * payload, /* in */ + uint8_t * out, + struct ipmi_rq * req, + uint8_t rq_seq, + uint8_t curr_seq)=0; + virtual void getSolPayloadWireRep( + struct ipmi_intf * intf, + uint8_t * msg, + struct ipmi_v2_payload * payload)=0; + virtual void read_open_session_response(struct ipmi_rs * rsp, int offset)=0; + virtual void read_rakp2_message(struct ipmi_rs * rsp, int offset, uint8_t alg)=0; + virtual void read_rakp4_message(struct ipmi_rs * rsp, int offset, uint8_t alg)=0; + virtual void read_session_data(struct ipmi_rs * rsp, int * offset, struct ipmi_session *s)=0; + virtual void read_session_data_v15(struct ipmi_rs * rsp, int * offset, struct ipmi_session *s)=0; + virtual void read_session_data_v2x(struct ipmi_rs * rsp, int * offset, struct ipmi_session *s)=0; + virtual void read_ipmi_response(struct ipmi_rs * rsp, int * offset)=0; + virtual void read_sol_packet(struct ipmi_rs * rsp, int * offset)=0; + virtual struct ipmi_rs * recv_sol(struct ipmi_intf * intf)=0; + virtual struct ipmi_rs * send_sol( + struct ipmi_intf * intf, + struct ipmi_v2_payload * payload)=0; + virtual int check_sol_packet_for_new_data( + struct ipmi_intf * intf, + struct ipmi_rs *rsp)=0; + virtual void ack_sol_packet( + struct ipmi_intf * intf, + struct ipmi_rs * rsp)=0; + virtual void set_max_rq_data_size(struct ipmi_intf * intf, uint16_t size)=0; + struct ipmi_rq_entry *ipmi_lanplus_build_v15_ipmi_cmd( + struct ipmi_intf * intf, + struct ipmi_rq * req); + +}; + + +#endif /* ONLINE_IPMI_SRC_NEWLIB_LANBASE_H_ */ diff --git a/Online/IPMI/src/NewLib/LANPlus.cpp b/Online/IPMI/src/NewLib/LANPlus.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1d424cf2d5fd93de6ae0d5c15105659cdf24fe09 --- /dev/null +++ b/Online/IPMI/src/NewLib/LANPlus.cpp @@ -0,0 +1,3629 @@ +/* + * LANPlus.h + * + * Created on: Jul 14, 2021 + * Author: beat + */ + + +#include "lanplus_dump.h" +#include "lanplus_crypt_impl.h" +#include "ipmi.h" +#include "lanplus_crypt.h" +#include "rmcp.h" +#include "asf.h" +#include "ipmi_intf.h" +#include "ipmi_session.h" +#include "ipmi.h" +#include "helper.h" +#include "ipmi_constants.h" +#include "ipmi_oem.h" +#include "hpm2.h" +#include "ipmi_sel.h" +#include "helper.h" +#include "LANPlus.h" +#include "ipmi_session.h" +#include "rmcp.h" +#include <cassert> +#include "log.h" +#include "helper.h" +#include "ipmi_strings.h" +#include "ipmi_channel.h" +#include <unistd.h> + + /* + * lanplus_get_requested_ciphers + * + * Set the authentication, integrity and encryption algorithms based + * on the cipher suite ID. See table 22-19 in the IPMIv2 spec for the + * source of this information. + * + * param cipher_suite_id [in] + * param auth_alg [out] + * param integrity_alg [out] + * param crypt_alg [out] + * + * returns 0 on success + * 1 on failure + */ +//using ipmi_Intf = ipmi_intf<LANPlus>; +extern int verbose; +int LANPlus::lanplus_get_requested_ciphers(int cipher_suite_id, + uint8_t * auth_alg, + uint8_t * integrity_alg, + uint8_t * crypt_alg) +{ +#ifdef HAVE_CRYPTO_SHA256 + if ((cipher_suite_id < 0) || (cipher_suite_id > 17)) { + return 1; + } +#else + if ((cipher_suite_id < 0) || (cipher_suite_id > 14)) + return 1; +#endif /* HAVE_CRYPTO_SHA256 */ + /* See table 22-19 for the source of the statement */ + switch (cipher_suite_id) + { + case 0: + *auth_alg = IPMI_AUTH_RAKP_NONE; + *integrity_alg = IPMI_INTEGRITY_NONE; + *crypt_alg = IPMI_CRYPT_NONE; + break; + case 1: + *auth_alg = IPMI_AUTH_RAKP_HMAC_SHA1; + *integrity_alg = IPMI_INTEGRITY_NONE; + *crypt_alg = IPMI_CRYPT_NONE; + break; + case 2: + *auth_alg = IPMI_AUTH_RAKP_HMAC_SHA1; + *integrity_alg = IPMI_INTEGRITY_HMAC_SHA1_96; + *crypt_alg = IPMI_CRYPT_NONE; + break; + case 3: + *auth_alg = IPMI_AUTH_RAKP_HMAC_SHA1; + *integrity_alg = IPMI_INTEGRITY_HMAC_SHA1_96; + *crypt_alg = IPMI_CRYPT_AES_CBC_128; + break; + case 4: + *auth_alg = IPMI_AUTH_RAKP_HMAC_SHA1; + *integrity_alg = IPMI_INTEGRITY_HMAC_SHA1_96; + *crypt_alg = IPMI_CRYPT_XRC4_128; + break; + case 5: + *auth_alg = IPMI_AUTH_RAKP_HMAC_SHA1; + *integrity_alg = IPMI_INTEGRITY_HMAC_SHA1_96; + *crypt_alg = IPMI_CRYPT_XRC4_40; + break; + case 6: + *auth_alg = IPMI_AUTH_RAKP_HMAC_MD5; + *integrity_alg = IPMI_INTEGRITY_NONE; + *crypt_alg = IPMI_CRYPT_NONE; + break; + case 7: + *auth_alg = IPMI_AUTH_RAKP_HMAC_MD5; + *integrity_alg = IPMI_INTEGRITY_HMAC_MD5_128; + *crypt_alg = IPMI_CRYPT_NONE; + break; + case 8: + *auth_alg = IPMI_AUTH_RAKP_HMAC_MD5; + *integrity_alg = IPMI_INTEGRITY_HMAC_MD5_128; + *crypt_alg = IPMI_CRYPT_AES_CBC_128; + break; + case 9: + *auth_alg = IPMI_AUTH_RAKP_HMAC_MD5; + *integrity_alg = IPMI_INTEGRITY_HMAC_MD5_128; + *crypt_alg = IPMI_CRYPT_XRC4_128; + break; + case 10: + *auth_alg = IPMI_AUTH_RAKP_HMAC_MD5; + *integrity_alg = IPMI_INTEGRITY_HMAC_MD5_128; + *crypt_alg = IPMI_CRYPT_XRC4_40; + break; + case 11: + *auth_alg = IPMI_AUTH_RAKP_HMAC_MD5; + *integrity_alg = IPMI_INTEGRITY_MD5_128; + *crypt_alg = IPMI_CRYPT_NONE; + break; + case 12: + *auth_alg = IPMI_AUTH_RAKP_HMAC_MD5; + *integrity_alg = IPMI_INTEGRITY_MD5_128; + *crypt_alg = IPMI_CRYPT_AES_CBC_128; + break; + case 13: + *auth_alg = IPMI_AUTH_RAKP_HMAC_MD5; + *integrity_alg = IPMI_INTEGRITY_MD5_128; + *crypt_alg = IPMI_CRYPT_XRC4_128; + break; + case 14: + *auth_alg = IPMI_AUTH_RAKP_HMAC_MD5; + *integrity_alg = IPMI_INTEGRITY_MD5_128; + *crypt_alg = IPMI_CRYPT_XRC4_40; + break; +#ifdef HAVE_CRYPTO_SHA256 + case 15: + *auth_alg = IPMI_AUTH_RAKP_HMAC_SHA256; + *integrity_alg = IPMI_INTEGRITY_NONE; + *crypt_alg = IPMI_CRYPT_NONE; + break; + case 16: + *auth_alg = IPMI_AUTH_RAKP_HMAC_SHA256; + *integrity_alg = IPMI_INTEGRITY_HMAC_SHA256_128; + *crypt_alg = IPMI_CRYPT_NONE; + break; + case 17: + *auth_alg = IPMI_AUTH_RAKP_HMAC_SHA256; + *integrity_alg = IPMI_INTEGRITY_HMAC_SHA256_128; + *crypt_alg = IPMI_CRYPT_AES_CBC_128; + break; +#endif /* HAVE_CRYPTO_SHA256 */ + } + + return 0; +} + + +/* + * Reverse the order of arbitrarily long strings of bytes + */ +LANPlus::~LANPlus() +{ + if (Crypt != 0) {delete Crypt;Crypt=0;}; + if (oemO != 0) {delete oemO;oemO=0;}; + if (auth != 0) {delete auth;auth=0;}; +} +void LANPlus::lanplus_swap( + uint8_t * buffer, + int length) +{ + int i; + uint8_t temp; + + for (i =0; i < length/2; ++i) + { + temp = buffer[i]; + buffer[i] = buffer[length - 1 - i]; + buffer[length - 1 - i] = temp; + } +} + + + +const struct valstr plus_payload_types_vals[] = { + { IPMI_PAYLOAD_TYPE_IPMI, "IPMI (0)" }, // IPMI Message + { IPMI_PAYLOAD_TYPE_SOL, "SOL (1)" }, // SOL (Serial over LAN) + { IPMI_PAYLOAD_TYPE_OEM, "OEM (2)" }, // OEM Explicid + + { IPMI_PAYLOAD_TYPE_RMCP_OPEN_REQUEST, "OpenSession Req (0x10)" }, + { IPMI_PAYLOAD_TYPE_RMCP_OPEN_RESPONSE,"OpenSession Resp (0x11)" }, + { IPMI_PAYLOAD_TYPE_RAKP_1, "RAKP1 (0x12)" }, + { IPMI_PAYLOAD_TYPE_RAKP_2, "RAKP2 (0x13)" }, + { IPMI_PAYLOAD_TYPE_RAKP_3, "RAKP3 (0x14)" }, + { IPMI_PAYLOAD_TYPE_RAKP_4, "RAKP4 (0x15)" }, + { 0x00, NULL }, +}; + + +ipmi_rq_entry<LANPlus> *LANPlus::ipmi_req_add_entry( struct ipmi_rq * req, uint8_t req_seq) +{ + ipmi_rq_entry<LANPlus> * e; + + e = new ipmi_rq_entry<LANPlus>;//(ipmi_rq_entry*)malloc(sizeof(struct ipmi_rq_entry)); + if (e == NULL) { + lPrintf(LOG_ERR, "ipmitool: malloc failure"); + return NULL; + } + e->zero(); +// memset(e, 0, sizeof(ipmi_rq_entry<LANPlus>)); + memcpy(&e->req, req, sizeof(struct ipmi_rq)); + + e->intf = intf; + e->rq_seq = req_seq; + + if (ipmi_req_entries == NULL) + ipmi_req_entries = e; + else + ipmi_req_entries_tail->next = e; + + ipmi_req_entries_tail = e; + lPrintf(LOG_DEBUG+3, "added list entry seq=0x%02x cmd=0x%02x", + e->rq_seq, e->req.msg.cmd); + return e; +} + + +ipmi_rq_entry<LANPlus> *LANPlus::ipmi_req_lookup_entry(uint8_t seq, uint8_t cmd) +{ + ipmi_rq_entry<LANPlus> * e = ipmi_req_entries; + + while (e && (e->rq_seq != seq || e->req.msg.cmd != cmd)) { + if (e == e->next) + return NULL; + e = e->next; + } + return e; +} + +void LANPlus::ipmi_req_remove_entry(uint8_t seq, uint8_t cmd) +{ + ipmi_rq_entry<LANPlus> * p, * e, * saved_next_entry; + + e = p = ipmi_req_entries; + + while (e && (e->rq_seq != seq || e->req.msg.cmd != cmd)) { + p = e; + e = e->next; + } + if (e) { + lPrintf(LOG_DEBUG+3, "removed list entry seq=0x%02x cmd=0x%02x", + seq, cmd); + saved_next_entry = e->next; + p->next = (p->next == e->next) ? NULL : e->next; + /* If entry being removed is first in list, fix up list head */ + if (ipmi_req_entries == e) { + if (ipmi_req_entries != p) + ipmi_req_entries = p; + else + ipmi_req_entries = saved_next_entry; + } + /* If entry being removed is last in list, fix up list tail */ + if (ipmi_req_entries_tail == e) { + if (ipmi_req_entries_tail != p) + ipmi_req_entries_tail = p; + else + ipmi_req_entries_tail = NULL; + } + + if (e->msg_data) { + free(e->msg_data); + e->msg_data = NULL; + } + free(e); + e = NULL; + } +} + +void LANPlus::ipmi_req_clear_entries(void) +{ + ipmi_rq_entry<LANPlus> * p, * e; + + e = ipmi_req_entries; + while (e) { + lPrintf(LOG_DEBUG+3, "cleared list entry seq=0x%02x cmd=0x%02x", + e->rq_seq, e->req.msg.cmd); + p = e->next; + free(e); + e = p; + } + + ipmi_req_entries = NULL; + ipmi_req_entries_tail = NULL; +} + + +int LANPlus::ipmi_send_packet( + uint8_t * data, int + data_len) +{ + if (verbose >= 5) + intf->helper->printbuf(data, data_len, ">> sending packet"); + + return send(intf->fd, data, data_len, 0); +} + + + +struct ipmi_rs *LANPlus::ipmi_recv_packet() +{ +// struct ipmi_rs rsp; + fd_set read_set, err_set; + struct timeval tmout; + int ret; + + FD_ZERO(&read_set); + FD_SET(intf->fd, &read_set); + + FD_ZERO(&err_set); + FD_SET(intf->fd, &err_set); + + tmout.tv_sec = intf->session->timeout; + tmout.tv_usec = 0; + + ret = select(intf->fd + 1, &read_set, NULL, &err_set, &tmout); + if (ret < 0 || FD_ISSET(intf->fd, &err_set) || !FD_ISSET(intf->fd, &read_set)) + return NULL; + + /* the first read may return ECONNREFUSED because the rmcp ping + * packet--sent to UDP port 623--will be processed by both the + * BMC and the OS. + * + * The problem with this is that the ECONNREFUSED takes + * priority over any other received datagram; that means that + * the Connection Refused shows up _before_ the response packet, + * regardless of the order they were sent out. (unless the + * response is read before the connection refused is returned) + */ + ret = recv(intf->fd, &rsp.data, IPMI_BUF_SIZE, 0); + + if (ret < 0) { + FD_ZERO(&read_set); + FD_SET(intf->fd, &read_set); + + FD_ZERO(&err_set); + FD_SET(intf->fd, &err_set); + + tmout.tv_sec = intf->session->timeout; + tmout.tv_usec = 0; + + ret = select(intf->fd + 1, &read_set, NULL, &err_set, &tmout); + if (ret < 0 || FD_ISSET(intf->fd, &err_set) || !FD_ISSET(intf->fd, &read_set)) + return NULL; + + ret = recv(intf->fd, &rsp.data, IPMI_BUF_SIZE, 0); + if (ret < 0) + return NULL; + } + + if (ret == 0) + return NULL; + + rsp.data[ret] = '\0'; + rsp.data_len = ret; + + if (verbose >= 5) + intf->helper->printbuf(rsp.data, rsp.data_len, "<< received packet"); + + return &rsp; +} + + + +/* + * parse response RMCP "pong" packet + * + * return -1 if ping response not received + * returns 0 if IPMI is NOT supported + * returns 1 if IPMI is supported + * + * udp.source = 0x026f // RMCP_UDP_PORT + * udp.dest = ? // udp.source from rmcp-ping + * udp.len = ? + * udp.check = ? + * rmcp.ver = 0x06 // RMCP Version 1.0 + * rmcp.__res = 0x00 // RESERVED + * rmcp.seq = 0xff // no RMCP ACK + * rmcp.class = 0x06 // RMCP_CLASS_ASF + * asf.iana = 0x000011be // ASF_RMCP_IANA + * asf.type = 0x40 // ASF_TYPE_PONG + * asf.tag = ? // asf.tag from rmcp-ping + * asf.__res = 0x00 // RESERVED + * asf.len = 0x10 // 16 bytes + * asf.data[3:0]= 0x000011be // IANA# = RMCP_ASF_IANA if no OEM + * asf.data[7:4]= 0x00000000 // OEM-defined (not for IPMI) + * asf.data[8] = 0x81 // supported entities + * // [7]=IPMI [6:4]=RES [3:0]=ASF_1.0 + * asf.data[9] = 0x00 // supported interactions (reserved) + * asf.data[f:a]= 0x000000000000 + */ + +int LANPlus::ipmi_handle_pong( struct ipmi_rs * rsp) +{ + struct rmcp_pong { + struct rmcp_hdr rmcp; + struct asf_hdr asf; + uint32_t iana; + uint32_t oem; + uint8_t sup_entities; + uint8_t sup_interact; + uint8_t reserved[6]; + } * pong; + + if (!rsp) + return -1; + + pong = (struct rmcp_pong *)rsp->data; + + if (verbose) + printf("Received IPMI/RMCP response packet: " + "IPMI%s Supported\n", + (pong->sup_entities & 0x80) ? "" : " NOT"); + + if (verbose > 1) + printf(" ASF Version %s\n" + " RMCP Version %s\n" + " RMCP Sequence %d\n" + " IANA Enterprise %lu\n\n", + (pong->sup_entities & 0x01) ? "1.0" : "unknown", + (pong->rmcp.ver == 6) ? "1.0" : "unknown", + pong->rmcp.seq, + (unsigned long)ntohl(pong->iana)); + + return (pong->sup_entities & 0x80) ? 1 : 0; +} + + +/* build and send RMCP presence ping packet + * + * RMCP ping + * + * udp.source = ? + * udp.dest = 0x026f // RMCP_UDP_PORT + * udp.len = ? + * udp.check = ? + * rmcp.ver = 0x06 // RMCP Version 1.0 + * rmcp.__res = 0x00 // RESERVED + * rmcp.seq = 0xff // no RMCP ACK + * rmcp.class = 0x06 // RMCP_CLASS_ASF + * asf.iana = 0x000011be // ASF_RMCP_IANA + * asf.type = 0x80 // ASF_TYPE_PING + * asf.tag = ? // ASF sequence number + * asf.__res = 0x00 // RESERVED + * asf.len = 0x00 + * + */ +int LANPlus::ipmiv2_ping() +{ + struct asf_hdr asf_ping = { + .iana = htonl(ASF_RMCP_IANA), + .type = ASF_TYPE_PING, + .tag = 0, + .__reserved = 0, + .len = 0 + }; + struct rmcp_hdr rmcp_ping = { + .ver = RMCP_VERSION_1, + .__reserved = 0, + .seq = 0xff, + .Class = RMCP_CLASS_ASF, + }; + uint8_t * data; + int len = sizeof(rmcp_ping) + sizeof(asf_ping); + int rv; + + data = (uint8_t *)malloc(len); + if (data == NULL) { + lPrintf(LOG_ERR, "ipmitool: malloc failure"); + return -1; + } + memset(data, 0, len); + memcpy(data, &rmcp_ping, sizeof(rmcp_ping)); + memcpy(data+sizeof(rmcp_ping), &asf_ping, sizeof(asf_ping)); + + lPrintf(LOG_DEBUG, "Sending IPMI/RMCP presence ping packet"); + + rv = ipmi_send_packet( data, len); + + free(data); + data = NULL; + + if (rv < 0) { + lPrintf(LOG_ERR, "Unable to send IPMI presence ping packet"); + return -1; + } + + if (ipmi_poll_recv() == 0) + return 0; + + return 1; +} + + +/** + * + * ipmi_lan_poll_single + * + * Receive whatever comes back. Ignore received packets that don't correspond + * to a request we've sent. + * + * Returns: the ipmi_rs packet describing the/a response we expect. + */ +struct ipmi_rs *LANPlus::ipmi_poll_single() +{ + struct rmcp_hdr * rmcp_rsp; +// struct ipmi_rs rsp; + struct ipmi_rs *rrsp; + ipmi_session<LANPlus> * session = intf->session; + int offset, rv; + uint16_t payload_size; + + /* receive packet */ + rrsp = ipmi_recv_packet(); + + /* check if no packet has come */ + if (rrsp == NULL) { + return NULL; + } + + /* parse response headers */ + rmcp_rsp = (struct rmcp_hdr *)rsp.data; + + if (rmcp_rsp->Class == RMCP_CLASS_ASF) { + /* might be ping response packet */ + rv = ipmi_handle_pong(rrsp); + return (rv <= 0) ? NULL : rrsp; + } + + if (rmcp_rsp->Class != RMCP_CLASS_IPMI) { + lPrintf(LOG_DEBUG, "Invalid RMCP class: %x", rmcp_rsp->Class); + /* read one more packet */ + return (struct ipmi_rs *)1; + } + + /* + * The authtype / payload type determines what we are receiving + */ + offset = 4; + + /*-------------------------------------------------------------------- + * + * The current packet could be one of several things: + * + * 1) An IPMI 1.5 packet (the response to our GET CHANNEL + * AUTHENTICATION CAPABILITIES request) + * 2) An RMCP+ message with an IPMI response payload + * 3) AN RMCP+ open session response + * 4) An RAKP-2 message (response to an RAKP 1 message) + * 5) An RAKP-4 message (response to an RAKP 3 message) + * 6) A Serial Over LAN packet + * 7) An Invalid packet (one that doesn't match a request) + * ------------------------------------------------------------------- + */ + + read_session_data(rrsp, &offset, session); + + /* + * Skip packets that are not intended for this session + */ + if ((session->v2_data.session_state == LANPLUS_STATE_ACTIVE) && + (rrsp->session.authtype == IPMI_SESSION_AUTHTYPE_RMCP_PLUS) && + (rrsp->session.id != intf->session->v2_data.console_id)) + { + lPrintf(LOG_INFO, "packet session id 0x%x does not " + "match active session 0x%0x", + rrsp->session.id, intf->session->v2_data.console_id); + lPrintf(LOG_ERR, "ERROR: Received an Unexpected message ID"); + /* read one more packet */ + return (struct ipmi_rs *)1; + } + + if (Crypt->has_valid_auth_code(rrsp, session) == 0) { + lPrintf(LOG_ERR, "ERROR: Received message with invalid authcode!"); + return NULL; + } + + if ((session->v2_data.session_state == LANPLUS_STATE_ACTIVE) && + (rrsp->session.authtype == IPMI_SESSION_AUTHTYPE_RMCP_PLUS) && + (rrsp->session.bEncrypted)) { + Crypt->decrypt_payload(session->v2_data.crypt_alg, + session->v2_data.k2, + rrsp->data + offset, + rrsp->session.msglen, + rrsp->data + offset, + &payload_size); + } else { + payload_size = rrsp->session.msglen; + } + + /* + * Handle IPMI responses (case #1 and #2) -- all IPMI responses + */ + if (rrsp->session.payloadtype == IPMI_PAYLOAD_TYPE_IPMI) { + ipmi_rq_entry<LANPlus> * entry; + int payload_start = offset; + int extra_data_length; + int loop = 1; + + while (loop--) { + /* fill-in response data */ + read_ipmi_response(rrsp, &offset); + + lPrintf(LOG_DEBUG+1, "<< IPMI Response Session Header"); + lPrintf(LOG_DEBUG+1, "<< Authtype : %s", + intf->helper->val2str(rrsp->session.authtype, ipmi_authtype_session_vals)); + lPrintf(LOG_DEBUG+1, "<< Payload type : %s", + intf->helper->val2str(rrsp->session.payloadtype, plus_payload_types_vals)); + lPrintf(LOG_DEBUG+1, "<< Session ID : 0x%08lx", + (long)rrsp->session.id); + lPrintf(LOG_DEBUG+1, "<< Sequence : 0x%08lx", + (long)rrsp->session.seq); + lPrintf(LOG_DEBUG+1, "<< IPMI Msg/Payload Length : %d", + rrsp->session.msglen); + lPrintf(LOG_DEBUG+1, "<< IPMI Response Message Header"); + lPrintf(LOG_DEBUG+1, "<< Rq Addr : %02x", + rrsp->payload.ipmi_response.rq_addr); + lPrintf(LOG_DEBUG+1, "<< NetFn : %02x", + rrsp->payload.ipmi_response.netfn); + lPrintf(LOG_DEBUG+1, "<< Rq LUN : %01x", + rrsp->payload.ipmi_response.rq_lun); + lPrintf(LOG_DEBUG+1, "<< Rs Addr : %02x", + rrsp->payload.ipmi_response.rs_addr); + lPrintf(LOG_DEBUG+1, "<< Rq Seq : %02x", + rrsp->payload.ipmi_response.rq_seq); + lPrintf(LOG_DEBUG+1, "<< Rs Lun : %01x", + rrsp->payload.ipmi_response.rs_lun); + lPrintf(LOG_DEBUG+1, "<< Command : %02x", + rrsp->payload.ipmi_response.cmd); + lPrintf(LOG_DEBUG+1, "<< Compl Code : 0x%02x", + rrsp->ccode); + + /* Are we expecting this packet? */ + entry = ipmi_req_lookup_entry(rrsp->payload.ipmi_response.rq_seq, + rrsp->payload.ipmi_response.cmd); + + if (entry == NULL) { + lPrintf(LOG_INFO, "IPMI Request Match NOT FOUND"); + /* read one more packet */ + return (struct ipmi_rs *)1; + }; + +// uint8_t target_cmd = entry->req.msg.target_cmd; + + lPrintf(LOG_DEBUG+2, "IPMI Request Match found"); + + if (entry->bridging_level) { + /* Check completion code */ + if (rrsp->ccode) { + lPrintf(LOG_DEBUG, "WARNING: Bridged " + "cmd ccode = 0x%02x", rrsp->ccode); + } else { + /* decrement bridging level */ + entry->bridging_level--; + if (!entry->bridging_level) { + entry->req.msg.cmd = entry->req.msg.target_cmd; + } + + /* check if bridged response is embedded */ + if (payload_size > 8) { + intf->helper->printbuf(&rrsp->data[offset], (rrsp->data_len-offset-1), + "bridge command response"); + /* + * decrement payload size + * (cks2 for outer Send Message) + */ + payload_size--; + + /* + * need to make a loop for embedded bridged response + */ + loop++; + } else { + lPrintf(LOG_DEBUG, "Bridged command answer," + " waiting for next answer... "); + /* read one more packet */ + return (struct ipmi_rs *)1; + } + } + } + + /* Remove request entry */ + ipmi_req_remove_entry(rrsp->payload.ipmi_response.rq_seq, + rrsp->payload.ipmi_response.cmd); + + /* + * Good packet. Shift response data to start of array. + * rrsp->data becomes the variable length IPMI response data + * rrsp->data_len becomes the length of that data + */ + extra_data_length = payload_size - (offset - payload_start) - 1; + if (extra_data_length) { + rrsp->data_len = extra_data_length; + memmove(rrsp->data, rrsp->data + offset, extra_data_length); + } else { + rrsp->data_len = 0; + } + } + /* + * Open Response + */ + } else if (rrsp->session.payloadtype == + IPMI_PAYLOAD_TYPE_RMCP_OPEN_RESPONSE) { + if (session->v2_data.session_state != + LANPLUS_STATE_OPEN_SESSION_SENT) { + lPrintf(LOG_ERR, "Error: Received an Unexpected Open Session " + "Response"); + /* read one more packet */ + return (struct ipmi_rs *)1; + } + read_open_session_response(rrsp, offset); + /* + * RAKP 2 + */ + } else if (rrsp->session.payloadtype == IPMI_PAYLOAD_TYPE_RAKP_2) { + if (session->v2_data.session_state != LANPLUS_STATE_RAKP_1_SENT) { + lPrintf(LOG_ERR, "Error: Received an Unexpected RAKP 2 message"); + /* read one more packet */ + return (struct ipmi_rs *)1; + } + read_rakp2_message(rrsp, offset, session->v2_data.auth_alg); + /* + * RAKP 4 + */ + } else if (rrsp->session.payloadtype == IPMI_PAYLOAD_TYPE_RAKP_4) { + if (session->v2_data.session_state != LANPLUS_STATE_RAKP_3_SENT) { + lPrintf(LOG_ERR, "Error: Received an Unexpected RAKP 4 message"); + /* read one more packet */ + return (struct ipmi_rs *)1; + } + read_rakp4_message(rrsp, offset, session->v2_data.auth_alg); + /* + * SOL + */ + } else if (rrsp->session.payloadtype == IPMI_PAYLOAD_TYPE_SOL) { + int payload_start = offset; + int extra_data_length; + + if (session->v2_data.session_state != LANPLUS_STATE_ACTIVE) { + lPrintf(LOG_ERR, "Error: Received an Unexpected SOL packet"); + /* read one more packet */ + return (struct ipmi_rs *)1; + } + read_sol_packet(rrsp, &offset); + extra_data_length = payload_size - (offset - payload_start); + if (rrsp && extra_data_length) { + rrsp->data_len = extra_data_length; + memmove(rrsp->data, rrsp->data + offset, extra_data_length); + } else { + rrsp->data_len = 0; + } + /* + * Unknown Payload type + */ + } else { + lPrintf(LOG_ERR, "Invalid RMCP+ payload type : 0x%x", + rrsp->session.payloadtype); + /* read one more packet */ + return (struct ipmi_rs *)1; + } + + return rrsp; +} + + + +/** + * + * ipmi_lan_poll_recv + * + * Receive whatever comes back. Ignore received packets that don't correspond + * to a request we've sent. + * + * Returns: the ipmi_rs packet describing the/a response we expect. + */ +struct ipmi_rs *LANPlus::ipmi_poll_recv() +{ + struct ipmi_rs * rsp; + + do { + /* poll single packet */ + rsp = ipmi_poll_single(); + } while (rsp == (struct ipmi_rs *) 1); + + return rsp; +} + + + +/* + * read_open_session_response + * + * Initialize the ipmi_rs from the IPMI 2.x open session response data. + * + * The offset should point to the first byte of the the Open Session Response + * payload when this function is called. + * + * param rsp [in/out] reading from the data and writing to the open_session_response + * section + * param offset [in] tells us where the Open Session Response payload starts + * + * returns 0 on success, 1 on error + */ +void LANPlus::read_open_session_response(struct ipmi_rs * rsp, int offset) +{ + memset(&rsp->payload.open_session_response, 0, + sizeof(rsp->payload.open_session_response)); + + /* Message tag */ + rsp->payload.open_session_response.message_tag = rsp->data[offset]; + + /* RAKP response code */ + rsp->payload.open_session_response.rakp_return_code = rsp->data[offset + 1]; + + /* Maximum privilege level */ + rsp->payload.open_session_response.max_priv_level = rsp->data[offset + 2]; + + /*** offset + 3 is reserved ***/ + + /* Remote console session ID */ + memcpy(&(rsp->payload.open_session_response.console_id), + rsp->data + offset + 4, + 4); + #if WORDS_BIGENDIAN + rsp->payload.open_session_response.console_id = + BSWAP_32(rsp->payload.open_session_response.console_id); + #endif + + /* only tag, status, privlvl, and console id are returned if error */ + if (rsp->payload.open_session_response.rakp_return_code != + IPMI_RAKP_STATUS_NO_ERRORS) + return; + + /* BMC session ID */ + memcpy(&(rsp->payload.open_session_response.bmc_id), + rsp->data + offset + 8, + 4); + #if WORDS_BIGENDIAN + rsp->payload.open_session_response.bmc_id = + BSWAP_32(rsp->payload.open_session_response.bmc_id); + #endif + + /* And of course, our negotiated algorithms */ + rsp->payload.open_session_response.auth_alg = rsp->data[offset + 16]; + rsp->payload.open_session_response.integrity_alg = rsp->data[offset + 24]; + rsp->payload.open_session_response.crypt_alg = rsp->data[offset + 32]; +} + + + +/* + * read_rakp2_message + * + * Initialize the ipmi_rs from the IPMI 2.x RAKP 2 message + * + * The offset should point the first byte of the the RAKP 2 payload when this + * function is called. + * + * param rsp [in/out] reading from the data variable and writing to the rakp 2 + * section + * param offset [in] tells us where hte rakp2 payload starts + * param auth_alg [in] describes the authentication algorithm was agreed upon in + * the open session request/response phase. We need to know that here so + * that we know how many bytes (if any) to read fromt the packet. + * + * returns 0 on success, 1 on error + */ +void LANPlus::read_rakp2_message( + struct ipmi_rs * rsp, + int offset, + uint8_t auth_alg) +{ + int i; + + /* Message tag */ + rsp->payload.rakp2_message.message_tag = rsp->data[offset]; + + /* RAKP response code */ + rsp->payload.rakp2_message.rakp_return_code = rsp->data[offset + 1]; + + /* Console session ID */ + memcpy(&(rsp->payload.rakp2_message.console_id), + rsp->data + offset + 4, + 4); + #if WORDS_BIGENDIAN + rsp->payload.rakp2_message.console_id = + BSWAP_32(rsp->payload.rakp2_message.console_id); + #endif + + /* BMC random number */ + memcpy(&(rsp->payload.rakp2_message.bmc_rand), + rsp->data + offset + 8, + 16); + #if WORDS_BIGENDIAN + lanplus_swap(rsp->payload.rakp2_message.bmc_rand, 16); + #endif + + /* BMC GUID */ + memcpy(&(rsp->payload.rakp2_message.bmc_guid), + rsp->data + offset + 24, + 16); + #if WORDS_BIGENDIAN + lanplus_swap(rsp->payload.rakp2_message.bmc_guid, 16); + #endif + + /* Key exchange authentication code */ + switch (auth_alg) + { + case IPMI_AUTH_RAKP_NONE: + /* Nothing to do here */ + break; + + case IPMI_AUTH_RAKP_HMAC_SHA1: + /* We need to copy 20 bytes */ + for (i = 0; i < IPMI_SHA_DIGEST_LENGTH; ++i) { + rsp->payload.rakp2_message.key_exchange_auth_code[i] = + rsp->data[offset + 40 + i]; + } + break; + + case IPMI_AUTH_RAKP_HMAC_MD5: + /* We need to copy 16 bytes */ + for (i = 0; i < IPMI_MD5_DIGEST_LENGTH; ++i) { + rsp->payload.rakp2_message.key_exchange_auth_code[i] = + rsp->data[offset + 40 + i]; + } + break; + +#ifdef HAVE_CRYPTO_SHA256 + case IPMI_AUTH_RAKP_HMAC_SHA256: + /* We need to copy 32 bytes */ + for (i = 0; i < IPMI_SHA256_DIGEST_LENGTH; ++i) { + rsp->payload.rakp2_message.key_exchange_auth_code[i] = + rsp->data[offset + 40 + i]; + } + break; +#endif /* HAVE_CRYPTO_SHA256 */ + + default: + lPrintf(LOG_ERR, "read_rakp2_message: no support " + "for authentication algorithm 0x%x", auth_alg); + assert(0); + break; + } +} + + + +/* + * read_rakp4_message + * + * Initialize the ipmi_rs from the IPMI 2.x RAKP 4 message + * + * The offset should point the first byte of the the RAKP 4 payload when this + * function is called. + * + * param rsp [in/out] reading from the data variable and writing to the rakp + * 4 section + * param offset [in] tells us where hte rakp4 payload starts + * param integrity_alg [in] describes the authentication algorithm was + * agreed upon in the open session request/response phase. We need + * to know that here so that we know how many bytes (if any) to read + * from the packet. + * + * returns 0 on success, 1 on error + */ +void +LANPlus::read_rakp4_message( + struct ipmi_rs * rsp, + int offset, + uint8_t auth_alg) +{ + int i; + + /* Message tag */ + rsp->payload.rakp4_message.message_tag = rsp->data[offset]; + + /* RAKP response code */ + rsp->payload.rakp4_message.rakp_return_code = rsp->data[offset + 1]; + + /* Console session ID */ + memcpy(&(rsp->payload.rakp4_message.console_id), + rsp->data + offset + 4, + 4); + #if WORDS_BIGENDIAN + rsp->payload.rakp4_message.console_id = + BSWAP_32(rsp->payload.rakp4_message.console_id); + #endif + + + /* Integrity check value */ + switch (auth_alg) + { + case IPMI_AUTH_RAKP_NONE: + /* Nothing to do here */ + break; + + case IPMI_AUTH_RAKP_HMAC_SHA1: + /* We need to copy 12 bytes */ + for (i = 0; i < IPMI_SHA1_AUTHCODE_SIZE; ++i) { + rsp->payload.rakp4_message.integrity_check_value[i] = + rsp->data[offset + 8 + i]; + } + break; + + case IPMI_AUTH_RAKP_HMAC_MD5: + /* We need to copy 16 bytes */ + for (i = 0; i < IPMI_HMAC_MD5_AUTHCODE_SIZE; ++i) { + rsp->payload.rakp4_message.integrity_check_value[i] = + rsp->data[offset + 8 + i]; + } + break; + +#ifdef HAVE_CRYPTO_SHA256 + case IPMI_AUTH_RAKP_HMAC_SHA256: + /* We need to copy 16 bytes */ + for (i = 0; i < IPMI_HMAC_SHA256_AUTHCODE_SIZE; ++i) { + rsp->payload.rakp4_message.integrity_check_value[i] = + rsp->data[offset + 8 + i]; + } + break; +#endif /* HAVE_CRYPTO_SHA256 */ + + default: + lPrintf(LOG_ERR, "read_rakp4_message: no support " + "for authentication algorithm 0x%x", auth_alg); + assert(0); + break; + } +} + + + + +/* + * read_session_data + * + * Initialize the ipmi_rsp from the session data in the packet + * + * The offset should point the first byte of the the IPMI session when this + * function is called. + * + * param rsp [in/out] we read from the data buffer and populate the session + * specific fields. + * param offset [in/out] should point to the beginning of the session when + * this function is called. The offset will be adjusted to + * point to the end of the session when this function exits. + * param session holds our session state + */ +void LANPlus::read_session_data( + struct ipmi_rs * rsp, + int * offset, + ipmi_session<LANPlus> *s) +{ + /* We expect to read different stuff depending on the authtype */ + rsp->session.authtype = rsp->data[*offset]; + + if (rsp->session.authtype == IPMI_SESSION_AUTHTYPE_RMCP_PLUS) + read_session_data_v2x(rsp, offset, s); + else + read_session_data_v15(rsp, offset, s); +} + + + +/* + * read_session_data_v2x + * + * Initialize the ipmi_rsp from the v2.x session header of the packet. + * + * The offset should point to the first byte of the the IPMI session when this + * function is called. When this function exits, offset will point to the + * start of payload. + * + * Should decrypt and perform integrity checking here? + * + * param rsp [in/out] we read from the data buffer and populate the session + * specific fields. + * param offset [in/out] should point to the beginning of the session when this + * function is called. The offset will be adjusted to point to + * the end of the session when this function exits. + * param s holds our session state + */ +void LANPlus::read_session_data_v2x( + struct ipmi_rs * rsp, + int * offset, + ipmi_session<LANPlus> * ) +{ + rsp->session.authtype = rsp->data[(*offset)++]; + + rsp->session.bEncrypted = (rsp->data[*offset] & 0x80 ? 1 : 0); + rsp->session.bAuthenticated = (rsp->data[*offset] & 0x40 ? 1 : 0); + + + /* Payload type */ + rsp->session.payloadtype = rsp->data[(*offset)++] & 0x3F; + + /* Session ID */ + memcpy(&rsp->session.id, rsp->data + *offset, 4); + *offset += 4; + #if WORDS_BIGENDIAN + rsp->session.id = BSWAP_32(rsp->session.id); + #endif + + + /* Ignored, so far */ + memcpy(&rsp->session.seq, rsp->data + *offset, 4); + *offset += 4; + #if WORDS_BIGENDIAN + rsp->session.seq = BSWAP_32(rsp->session.seq); + #endif + + memcpy(&rsp->session.msglen, rsp->data + *offset, 2); + *offset += 2; + #if WORDS_BIGENDIAN + rsp->session.msglen = BSWAP_16(rsp->session.msglen); + #endif +} + + + +/* + * read_session_data_v15 + * + * Initialize the ipmi_rsp from the session header of the packet. + * + * The offset should point the first byte of the the IPMI session when this + * function is called. When this function exits, the offset will point to + * the start of the IPMI message. + * + * param rsp [in/out] we read from the data buffer and populate the session + * specific fields. + * param offset [in/out] should point to the beginning of the session when this + * function is called. The offset will be adjusted to point to the + * end of the session when this function exits. + * param s holds our session state + */ +void LANPlus::read_session_data_v15( + struct ipmi_rs * rsp, + int * offset, + ipmi_session<LANPlus> * ) +{ + /* All v15 messages are IPMI messages */ + rsp->session.payloadtype = IPMI_PAYLOAD_TYPE_IPMI; + + rsp->session.authtype = rsp->data[(*offset)++]; + + /* All v15 messages that we will receive are unencrypted/unauthenticated */ + rsp->session.bEncrypted = 0; + rsp->session.bAuthenticated = 0; + + /* skip the session id and sequence number fields */ + *offset += 8; + + /* This is the size of the whole payload */ + rsp->session.msglen = rsp->data[(*offset)++]; +} + + + +/* + * read_ipmi_response + * + * Initialize the ipmi_rs from with the IPMI response specific data + * + * The offset should point the first byte of the the IPMI payload when this + * function is called. + * + * param rsp [in/out] we read from the data buffer and populate the IPMI + * specific fields. + * param offset [in/out] should point to the beginning of the IPMI payload when + * this function is called. + */ +void LANPlus::read_ipmi_response(struct ipmi_rs * rsp, int * offset) +{ + /* + * The data here should be decrypted by now. + */ + rsp->payload.ipmi_response.rq_addr = rsp->data[(*offset)++]; + rsp->payload.ipmi_response.netfn = rsp->data[*offset] >> 2; + rsp->payload.ipmi_response.rq_lun = rsp->data[(*offset)++] & 0x3; + (*offset)++; /* checksum */ + rsp->payload.ipmi_response.rs_addr = rsp->data[(*offset)++]; + rsp->payload.ipmi_response.rq_seq = rsp->data[*offset] >> 2; + rsp->payload.ipmi_response.rs_lun = rsp->data[(*offset)++] & 0x3; + rsp->payload.ipmi_response.cmd = rsp->data[(*offset)++]; + rsp->ccode = rsp->data[(*offset)++]; + +} + + + +/* + * read_sol_packet + * + * Initialize the ipmi_rs with the SOL response data + * + * The offset should point the first byte of the the SOL payload when this + * function is called. + * + * param rsp [in/out] we read from the data buffer and populate the + * SOL specific fields. + * param offset [in/out] should point to the beginning of the SOL payload + * when this function is called. + */ +void LANPlus::read_sol_packet(struct ipmi_rs * rsp, int * offset) +{ + + /* + * The data here should be decrypted by now. + */ + rsp->payload.sol_packet.packet_sequence_number = + rsp->data[(*offset)++] & 0x0F; + + rsp->payload.sol_packet.acked_packet_number = + rsp->data[(*offset)++] & 0x0F; + + rsp->payload.sol_packet.accepted_character_count = + rsp->data[(*offset)++]; + + rsp->payload.sol_packet.is_nack = + rsp->data[*offset] & 0x40; + + rsp->payload.sol_packet.transfer_unavailable = + rsp->data[*offset] & 0x20; + + rsp->payload.sol_packet.sol_inactive = + rsp->data[*offset] & 0x10; + + rsp->payload.sol_packet.transmit_overrun = + rsp->data[*offset] & 0x08; + + rsp->payload.sol_packet.break_detected = + rsp->data[(*offset)++] & 0x04; + + lPrintf(LOG_DEBUG, "<<<<<<<<<< RECV FROM BMC <<<<<<<<<<<"); + lPrintf(LOG_DEBUG, "< SOL sequence number : 0x%02x", + rsp->payload.sol_packet.packet_sequence_number); + lPrintf(LOG_DEBUG, "< SOL acked packet : 0x%02x", + rsp->payload.sol_packet.acked_packet_number); + lPrintf(LOG_DEBUG, "< SOL accepted char count : 0x%02x", + rsp->payload.sol_packet.accepted_character_count); + lPrintf(LOG_DEBUG, "< SOL is nack : %s", + rsp->payload.sol_packet.is_nack? "true" : "false"); + lPrintf(LOG_DEBUG, "< SOL xfer unavailable : %s", + rsp->payload.sol_packet.transfer_unavailable? "true" : "false"); + lPrintf(LOG_DEBUG, "< SOL inactive : %s", + rsp->payload.sol_packet.sol_inactive? "true" : "false"); + lPrintf(LOG_DEBUG, "< SOL transmit overrun : %s", + rsp->payload.sol_packet.transmit_overrun? "true" : "false"); + lPrintf(LOG_DEBUG, "< SOL break detected : %s", + rsp->payload.sol_packet.break_detected? "true" : "false"); + lPrintf(LOG_DEBUG, "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"); + + if (verbose >= 5) + intf->helper->printbuf(rsp->data + *offset - 4, 4, "SOL MSG FROM BMC"); +} + + + +/* + * getIpmiPayloadWireRep + * + * param out [out] will contain our wire representation + * param req [in] is the IPMI request to be written + * param crypt_alg [in] specifies the encryption to use + * param rq_seq [in] is the IPMI command sequence number. + */ +void LANPlus::getIpmiPayloadWireRep( + struct ipmi_v2_payload * payload, /* in */ + uint8_t * msg, + struct ipmi_rq * req, + uint8_t rq_seq, + uint8_t curr_seq) +{ + int cs, tmp, len; + int cs2 = 0; + int cs3 = 0; + uint8_t ourAddress = intf->my_addr; + uint8_t bridgedRequest = 0; + + if (ourAddress == 0) + ourAddress = IPMI_BMC_SLAVE_ADDR; + + len = 0; + + /* IPMI Message Header -- Figure 13-4 of the IPMI v2.0 spec */ + if ((intf->target_addr == ourAddress) || (!bridgePossible)) { + cs = len; + } else { + bridgedRequest = 1; + + if(intf->transit_addr != ourAddress && intf->transit_addr != 0) + { + bridgedRequest++; + } + /* bridged request: encapsulate w/in Send Message */ + cs = len; + msg[len++] = IPMI_BMC_SLAVE_ADDR; + msg[len++] = IPMI_NETFN_APP << 2; + tmp = len - cs; + msg[len++] = intf->helper->ipmi_csum(msg+cs, tmp); + cs2 = len; + msg[len++] = IPMI_REMOTE_SWID; + msg[len++] = curr_seq << 2; + + + msg[len++] = 0x34; /* Send Message rqst */ + if(bridgedRequest == 2) + msg[len++] = (0x40|intf->transit_channel); /* Track request*/ + else + msg[len++] = (0x40|intf->target_channel); /* Track request*/ + + payload->payload_length += 7; + cs = len; + + if(bridgedRequest == 2) + { + /* bridged request: encapsulate w/in Send Message */ + cs = len; + msg[len++] = intf->transit_addr; + msg[len++] = IPMI_NETFN_APP << 2; + tmp = len - cs; + msg[len++] = intf->helper->ipmi_csum(msg+cs, tmp); + cs3 = len; + msg[len++] = IPMI_REMOTE_SWID; + msg[len++] = curr_seq << 2; + msg[len++] = 0x34; /* Send Message rqst */ + msg[len++] = (0x40|intf->target_channel); /* Track request*/ + + payload->payload_length += 7; + + cs = len; + } + } + + lPrintf(LOG_DEBUG,"%s RqAddr %#x transit %#x:%#x target %#x:%#x " + "bridgePossible %d", + bridgedRequest ? "Bridging" : "Local", + intf->my_addr, intf->transit_addr, intf->transit_channel, + intf->target_addr, intf->target_channel, + bridgePossible); + + /* rsAddr */ + if (bridgedRequest) + msg[len++] = intf->target_addr; + else + msg[len++] = IPMI_BMC_SLAVE_ADDR; + + /* net Fn */ + msg[len++] = req->msg.netfn << 2 | (req->msg.lun & 3); + tmp = len - cs; + + /* checkSum */ + msg[len++] = intf->helper->ipmi_csum(msg+cs, tmp); + cs = len; + + /* rqAddr */ + if (bridgedRequest < 2) + msg[len++] = IPMI_REMOTE_SWID; + else /* Bridged message */ + msg[len++] = intf->my_addr; + + /* rqSeq / rqLUN */ + msg[len++] = rq_seq << 2; + + /* cmd */ + msg[len++] = req->msg.cmd; + + /* message data */ + if (req->msg.data_len) { + memcpy(msg + len, req->msg.data, req->msg.data_len); + len += req->msg.data_len; + } + + /* second checksum */ + tmp = len - cs; + msg[len++] = intf->helper->ipmi_csum(msg+cs, tmp); + + /* Dual bridged request: 2nd checksum */ + if (bridgedRequest == 2) { + tmp = len - cs3; + msg[len++] = intf->helper->ipmi_csum(msg+cs3, tmp); + payload->payload_length += 1; + } + + /* bridged request: 2nd checksum */ + if (bridgedRequest) { + tmp = len - cs2; + msg[len++] = intf->helper->ipmi_csum(msg+cs2, tmp); + payload->payload_length += 1; + } +} + + + +/* + * getSolPayloadWireRep + * + * param msg [out] will contain our wire representation + * param payload [in] holds the v2 payload with our SOL data + */ +void LANPlus::getSolPayloadWireRep( + ipmi_Intf * intf, /* in out */ + uint8_t * msg, /* output */ + struct ipmi_v2_payload * payload) /* input */ +{ + int i = 0; + + lPrintf(LOG_DEBUG, ">>>>>>>>>> SENDING TO BMC >>>>>>>>>>"); + lPrintf(LOG_DEBUG, "> SOL sequence number : 0x%02x", + payload->payload.sol_packet.packet_sequence_number); + lPrintf(LOG_DEBUG, "> SOL acked packet : 0x%02x", + payload->payload.sol_packet.acked_packet_number); + lPrintf(LOG_DEBUG, "> SOL accepted char count : 0x%02x", + payload->payload.sol_packet.accepted_character_count); + lPrintf(LOG_DEBUG, "> SOL is nack : %s", + payload->payload.sol_packet.is_nack ? "true" : "false"); + lPrintf(LOG_DEBUG, "> SOL assert ring wor : %s", + payload->payload.sol_packet.assert_ring_wor ? "true" : "false"); + lPrintf(LOG_DEBUG, "> SOL generate break : %s", + payload->payload.sol_packet.generate_break ? "true" : "false"); + lPrintf(LOG_DEBUG, "> SOL deassert cts : %s", + payload->payload.sol_packet.deassert_cts ? "true" : "false"); + lPrintf(LOG_DEBUG, "> SOL deassert dcd dsr : %s", + payload->payload.sol_packet.deassert_dcd_dsr ? "true" : "false"); + lPrintf(LOG_DEBUG, "> SOL flush inbound : %s", + payload->payload.sol_packet.flush_inbound ? "true" : "false"); + lPrintf(LOG_DEBUG, "> SOL flush outbound : %s", + payload->payload.sol_packet.flush_outbound ? "true" : "false"); + + msg[i++] = payload->payload.sol_packet.packet_sequence_number; + msg[i++] = payload->payload.sol_packet.acked_packet_number; + msg[i++] = payload->payload.sol_packet.accepted_character_count; + + msg[i] = payload->payload.sol_packet.is_nack ? 0x40 : 0; + msg[i] |= payload->payload.sol_packet.assert_ring_wor ? 0x20 : 0; + msg[i] |= payload->payload.sol_packet.generate_break ? 0x10 : 0; + msg[i] |= payload->payload.sol_packet.deassert_cts ? 0x08 : 0; + msg[i] |= payload->payload.sol_packet.deassert_dcd_dsr ? 0x04 : 0; + msg[i] |= payload->payload.sol_packet.flush_inbound ? 0x02 : 0; + msg[i++] |= payload->payload.sol_packet.flush_outbound ? 0x01 : 0; + + /* We may have data to add */ + memcpy(msg + i, + payload->payload.sol_packet.data, + payload->payload.sol_packet.character_count); + + lPrintf(LOG_DEBUG, "> SOL character count : %d", + payload->payload.sol_packet.character_count); + lPrintf(LOG_DEBUG, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + + if (verbose >= 5 && payload->payload.sol_packet.character_count) + intf->helper->printbuf(payload->payload.sol_packet.data, payload->payload.sol_packet.character_count, "SOL SEND DATA"); + + /* + * At this point, the payload length becomes the whole payload + * length, including the 4 bytes at the beginning of the SOL + * packet + */ + payload->payload_length = payload->payload.sol_packet.character_count + 4; +} + + + +/* + * ipmi_lanplus_build_v2x_msg + * + * Encapsulates the payload data to create the IPMI v2.0 / RMCP+ packet. + * + * + * IPMI v2.0 LAN Request Message Format + * +----------------------+ + * | rmcp.ver | 4 bytes + * | rmcp.__reserved | + * | rmcp.seq | + * | rmcp.class | + * +----------------------+ + * | session.authtype | 10 bytes + * | session.payloadtype | + * | session.id | + * | session.seq | + * +----------------------+ + * | message length | 2 bytes + * +----------------------+ + * | Confidentiality Hdr | var (possibly absent) + * +----------------------+ + * | Paylod | var Payload + * +----------------------+ + * | Confidentiality Trlr | var (possibly absent) + * +----------------------+ + * | Integrity pad | var (possibly absent) + * +----------------------+ + * | Pad length | 1 byte (WTF?) + * +----------------------+ + * | Next Header | 1 byte (WTF?) + * +----------------------+ + * | Authcode | var (possibly absent) + * +----------------------+ + */ +void +LANPlus::ipmi_build_v2x_msg( + ipmi_Intf * intf, /* in */ + struct ipmi_v2_payload * payload, /* in */ + int * msg_len, /* out */ + uint8_t ** msg_data, /* out */ + uint8_t curr_seq) +{ + uint32_t session_trailer_length = 0; + ipmi_session<LANPlus> * session = intf->session; + struct rmcp_hdr rmcp = { + .ver = RMCP_VERSION_1, + .__reserved =0, + .seq = 0xff, + .Class = RMCP_CLASS_IPMI, + }; + + /* msg will hold the entire message to be sent */ + uint8_t * msg; + int len = 0; + + + len = + sizeof(rmcp) + // RMCP Header (4) + 10 + // IPMI Session Header + 2 + // Message length + payload->payload_length + // The actual payload + IPMI_MAX_INTEGRITY_PAD_SIZE + // Integrity Pad + 1 + // Pad Length + 1 + // Next Header + IPMI_MAX_AUTH_CODE_SIZE; // Authcode + + + msg = (uint8_t *)malloc(len); + if (msg == NULL) { + lPrintf(LOG_ERR, "ipmitool: malloc failure"); + return; + } + memset(msg, 0, len); + + /* + *------------------------------------------ + * RMCP HEADER + *------------------------------------------ + */ + memcpy(msg, &rmcp, sizeof(rmcp)); + len = sizeof(rmcp); + + + /* + *------------------------------------------ + * IPMI SESSION HEADER + *------------------------------------------ + */ + /* ipmi session Auth Type / Format is always 0x06 for IPMI v2 */ + msg[IPMI_LANPLUS_OFFSET_AUTHTYPE] = 0x06; + + /* Payload Type -- also specifies whether were authenticated/encyrpted */ + msg[IPMI_LANPLUS_OFFSET_PAYLOAD_TYPE] = payload->payload_type; + + if (session->v2_data.session_state == LANPLUS_STATE_ACTIVE) + { + msg[IPMI_LANPLUS_OFFSET_PAYLOAD_TYPE] |= + ((session->v2_data.crypt_alg != IPMI_CRYPT_NONE )? 0x80 : 0x00); + msg[IPMI_LANPLUS_OFFSET_PAYLOAD_TYPE] |= + ((session->v2_data.integrity_alg != IPMI_INTEGRITY_NONE)? 0x40 : 0x00); + } + + if (session->v2_data.session_state == LANPLUS_STATE_ACTIVE) + { + /* Session ID -- making it LSB */ + msg[IPMI_LANPLUS_OFFSET_SESSION_ID ] = session->v2_data.bmc_id & 0xff; + msg[IPMI_LANPLUS_OFFSET_SESSION_ID + 1] = (session->v2_data.bmc_id >> 8) & 0xff; + msg[IPMI_LANPLUS_OFFSET_SESSION_ID + 2] = (session->v2_data.bmc_id >> 16) & 0xff; + msg[IPMI_LANPLUS_OFFSET_SESSION_ID + 3] = (session->v2_data.bmc_id >> 24) & 0xff; + + /* Sequence Number -- making it LSB */ + msg[IPMI_LANPLUS_OFFSET_SEQUENCE_NUM ] = session->out_seq & 0xff; + msg[IPMI_LANPLUS_OFFSET_SEQUENCE_NUM + 1] = (session->out_seq >> 8) & 0xff; + msg[IPMI_LANPLUS_OFFSET_SEQUENCE_NUM + 2] = (session->out_seq >> 16) & 0xff; + msg[IPMI_LANPLUS_OFFSET_SEQUENCE_NUM + 3] = (session->out_seq >> 24) & 0xff; + } + + /* + * Payload Length is set below (we don't know how big the payload is until after + * encryption). + */ + + /* + * Payload + * + * At this point we are ready to slam the payload in. + * This includes: + * 1) The confidentiality header + * 2) The payload proper (possibly encrypted) + * 3) The confidentiality trailer + * + */ + switch (payload->payload_type) + { + case IPMI_PAYLOAD_TYPE_IPMI: + getIpmiPayloadWireRep( + payload, /* in */ + msg + IPMI_LANPLUS_OFFSET_PAYLOAD, + payload->payload.ipmi_request.request, + payload->payload.ipmi_request.rq_seq, + curr_seq); + break; + + case IPMI_PAYLOAD_TYPE_SOL: + getSolPayloadWireRep(intf, + msg + IPMI_LANPLUS_OFFSET_PAYLOAD, + payload); + + if (verbose >= 5) + intf->helper->printbuf(msg + IPMI_LANPLUS_OFFSET_PAYLOAD, 4, "SOL MSG TO BMC"); + + len += payload->payload_length; + + break; + + case IPMI_PAYLOAD_TYPE_RMCP_OPEN_REQUEST: + /* never encrypted, so our job is easy */ + memcpy(msg + IPMI_LANPLUS_OFFSET_PAYLOAD, + payload->payload.open_session_request.request, + payload->payload_length); + len += payload->payload_length; + break; + + case IPMI_PAYLOAD_TYPE_RAKP_1: + /* never encrypted, so our job is easy */ + memcpy(msg + IPMI_LANPLUS_OFFSET_PAYLOAD, + payload->payload.rakp_1_message.message, + payload->payload_length); + len += payload->payload_length; + break; + + case IPMI_PAYLOAD_TYPE_RAKP_3: + /* never encrypted, so our job is easy */ + memcpy(msg + IPMI_LANPLUS_OFFSET_PAYLOAD, + payload->payload.rakp_3_message.message, + payload->payload_length); + len += payload->payload_length; + break; + + default: + lPrintf(LOG_ERR, "unsupported payload type 0x%x", + payload->payload_type); + free(msg); + msg = NULL; + assert(0); + break; + } + + + /* + *------------------------------------------ + * ENCRYPT THE PAYLOAD IF NECESSARY + *------------------------------------------ + */ + if (session->v2_data.session_state == LANPLUS_STATE_ACTIVE) + { + /* Payload len is adjusted as necessary by lanplus_encrypt_payload */ + Crypt->encrypt_payload(session->v2_data.crypt_alg, /* input */ + session->v2_data.k2, /* input */ + msg + IPMI_LANPLUS_OFFSET_PAYLOAD, /* input */ + payload->payload_length, /* input */ + msg + IPMI_LANPLUS_OFFSET_PAYLOAD, /* output */ + &(payload->payload_length)); /* output */ + + } + + /* Now we know the payload length */ + msg[IPMI_LANPLUS_OFFSET_PAYLOAD_SIZE ] = + payload->payload_length & 0xff; + msg[IPMI_LANPLUS_OFFSET_PAYLOAD_SIZE + 1] = + (payload->payload_length >> 8) & 0xff; + + + /* + *------------------------------------------ + * SESSION TRAILER + *------------------------------------------ + */ + if ((session->v2_data.session_state == LANPLUS_STATE_ACTIVE) && + (session->v2_data.integrity_alg != IPMI_INTEGRITY_NONE)) + { + uint32_t i; + uint32_t hmac_length; + uint32_t auth_length = 0; + uint32_t integrity_pad_size = 0; + uint32_t hmac_input_size; + uint8_t * hmac_output; + uint32_t start_of_session_trailer = + IPMI_LANPLUS_OFFSET_PAYLOAD + + payload->payload_length; + + + /* + * Determine the required integrity pad length. We have to make the + * data range covered by the authcode a multiple of 4. + */ + uint32_t length_before_authcode; + + if (oemO->ipmi_oem_active( "icts")) { + length_before_authcode = + 12 + /* the stuff before the payload */ + payload->payload_length; + } else { + length_before_authcode = + 12 + /* the stuff before the payload */ + payload->payload_length + + 1 + /* pad length field */ + 1; /* next header field */ + } + + if (length_before_authcode % 4) + integrity_pad_size = 4 - (length_before_authcode % 4); + + for (i = 0; i < integrity_pad_size; ++i) + msg[start_of_session_trailer + i] = 0xFF; + + /* Pad length */ + msg[start_of_session_trailer + integrity_pad_size] = integrity_pad_size; + + /* Next Header */ + msg[start_of_session_trailer + integrity_pad_size + 1] = + 0x07; /* Hardcoded per the spec, table 13-8 */ + + hmac_input_size = + 12 + + payload->payload_length + + integrity_pad_size + + 2; + + hmac_output = + msg + + IPMI_LANPLUS_OFFSET_PAYLOAD + + payload->payload_length + + integrity_pad_size + + 2; + + if (verbose > 2) + intf->helper->printbuf(msg + IPMI_LANPLUS_OFFSET_AUTHTYPE, hmac_input_size, "authcode input"); + + + /* Auth Code */ + HMAC(session->v2_data.integrity_alg, + session->v2_data.k1, /* key */ + session->v2_data.k1_len, /* key length */ + msg + IPMI_LANPLUS_OFFSET_AUTHTYPE, /* hmac input */ + hmac_input_size, + hmac_output, + &hmac_length); + + switch(session->v2_data.integrity_alg) { + case IPMI_INTEGRITY_HMAC_SHA1_96: + assert(hmac_length == IPMI_SHA_DIGEST_LENGTH); + auth_length = IPMI_SHA1_AUTHCODE_SIZE; + break; + case IPMI_INTEGRITY_HMAC_MD5_128 : + assert(hmac_length == IPMI_MD5_DIGEST_LENGTH); + auth_length = IPMI_HMAC_MD5_AUTHCODE_SIZE; + break; +#ifdef HAVE_CRYPTO_SHA256 + case IPMI_INTEGRITY_HMAC_SHA256_128: + assert(hmac_length == IPMI_SHA256_DIGEST_LENGTH); + auth_length = IPMI_HMAC_SHA256_AUTHCODE_SIZE; + break; +#endif /* HAVE_CRYPTO_SHA256 */ + default: + assert(0); + break; + } + + if (verbose > 2) + intf->helper->printbuf(hmac_output, auth_length, "authcode output"); + + /* Set session_trailer_length appropriately */ + session_trailer_length = + integrity_pad_size + + 2 + /* pad length + next header */ + auth_length; /* Size of the authcode. We only + * use the first 12(SHA1) or + * 16(MD5/SHA256) bytes. + */ + } + + + ++(session->out_seq); + if (!session->out_seq) + ++(session->out_seq); + + *msg_len = + IPMI_LANPLUS_OFFSET_PAYLOAD + + payload->payload_length + + session_trailer_length; + *msg_data = msg; +} + + + +/* + * ipmi_lanplus_build_v2x_ipmi_cmd + * + * Wraps ipmi_lanplus_build_v2x_msg and returns a new entry object for the + * command + * + */ +ipmi_rq_entry<LANPlus> *LANPlus::ipmi_build_v2x_ipmi_cmd( + struct ipmi_rq * req, + int isRetry) +{ + struct ipmi_v2_payload v2_payload; + ipmi_rq_entry<LANPlus> * entry; + + /* + * We have a problem. we need to know the sequence number here, + * because we use it in our stored entry. But we also need to + * know the sequence number when we generate our IPMI + * representation far below. + */ + uint8_t curr_seq = 0; + + if( isRetry == 0 ) + curr_seq += 1; + + if (curr_seq >= 64) + curr_seq = 0; + + + /* IPMI Message Header -- Figure 13-4 of the IPMI v2.0 spec */ + if ((intf->target_addr == intf->my_addr) || (!bridgePossible)) { + entry = ipmi_req_add_entry( req, curr_seq); + /* it's a bridge command */ + } else { +// unsigned char backup_cmd; + + /* Add entry for cmd */ + entry = ipmi_req_add_entry( req, curr_seq); + + if (entry) { + entry->req.msg.target_cmd = entry->req.msg.cmd; + entry->req.msg.cmd = 0x34; + + if (intf->transit_addr && + intf->transit_addr != intf->my_addr) + entry->bridging_level = 2; + else + entry->bridging_level = 1; + } + } + + if (entry == NULL) + return NULL; + + // Build our payload + v2_payload.payload_type = IPMI_PAYLOAD_TYPE_IPMI; + v2_payload.payload_length = req->msg.data_len + 7; + v2_payload.payload.ipmi_request.request = req; + v2_payload.payload.ipmi_request.rq_seq = curr_seq; + + ipmi_build_v2x_msg(intf, // in + &v2_payload, // in + &(entry->msg_len), // out + &(entry->msg_data), // out + curr_seq); // in + + return entry; +} + + + + + +/* + * IPMI LAN Request Message Format + * +--------------------+ + * | rmcp.ver | 4 bytes + * | rmcp.__reserved | + * | rmcp.seq | + * | rmcp.class | + * +--------------------+ + * | session.authtype | 9 bytes + * | session.seq | + * | session.id | + * +--------------------+ + * | [session.authcode] | 16 bytes (AUTHTYPE != none) + * +--------------------+ + * | message length | 1 byte + * +--------------------+ + * | message.rs_addr | 6 bytes + * | message.netfn_lun | + * | message.checksum | + * | message.rq_addr | + * | message.rq_seq | + * | message.cmd | + * +--------------------+ + * | [request data] | data_len bytes + * +--------------------+ + * | checksum | 1 byte + * +--------------------+ + */ +ipmi_rq_entry<LANPlus> *LANPlus::ipmi_build_v15_ipmi_cmd( + struct ipmi_rq * req) +{ + struct rmcp_hdr rmcp = { + .ver = RMCP_VERSION_1, + .__reserved = 0, + .seq = 0xff, + .Class = RMCP_CLASS_IPMI, + }; + uint8_t * msg; + int cs, mp, len = 0, tmp; + ipmi_session<LANPlus> * session = intf->session; + ipmi_rq_entry<LANPlus> * entry; + + entry = ipmi_req_add_entry( req, 0); + if (entry == NULL) + return NULL; + + len = req->msg.data_len + 21; + + msg = (uint8_t*)malloc(len); + if (msg == NULL) { + lPrintf(LOG_ERR, "ipmitool: malloc failure"); + return NULL; + } + memset(msg, 0, len); + + /* rmcp header */ + memcpy(msg, &rmcp, sizeof(rmcp)); + len = sizeof(rmcp); + + /* + * ipmi session header + */ + /* Authtype should always be none for 1.5 packets sent from this + * interface + */ + msg[len++] = IPMI_SESSION_AUTHTYPE_NONE; + + msg[len++] = session->out_seq & 0xff; + msg[len++] = (session->out_seq >> 8) & 0xff; + msg[len++] = (session->out_seq >> 16) & 0xff; + msg[len++] = (session->out_seq >> 24) & 0xff; + + /* + * The session ID should be all zeroes for pre-session commands. We + * should only be using the 1.5 interface for the pre-session Get + * Channel Authentication Capabilities command + */ + msg[len++] = 0; + msg[len++] = 0; + msg[len++] = 0; + msg[len++] = 0; + + /* message length */ + msg[len++] = req->msg.data_len + 7; + + /* ipmi message header */ + cs = mp = len; + msg[len++] = IPMI_BMC_SLAVE_ADDR; + msg[len++] = req->msg.netfn << 2; + tmp = len - cs; + msg[len++] = intf->helper->ipmi_csum(msg+cs, tmp); + cs = len; + msg[len++] = IPMI_REMOTE_SWID; + + entry->rq_seq = 0; + + msg[len++] = entry->rq_seq << 2; + msg[len++] = req->msg.cmd; + + lPrintf(LOG_DEBUG+1, ">> IPMI Request Session Header"); + lPrintf(LOG_DEBUG+1, ">> Authtype : %s", + intf->helper->val2str(IPMI_SESSION_AUTHTYPE_NONE, ipmi_authtype_session_vals)); + lPrintf(LOG_DEBUG+1, ">> Sequence : 0x%08lx", + (long)session->out_seq); + lPrintf(LOG_DEBUG+1, ">> Session ID : 0x%08lx", + (long)0); + + lPrintf(LOG_DEBUG+1, ">> IPMI Request Message Header"); + lPrintf(LOG_DEBUG+1, ">> Rs Addr : %02x", IPMI_BMC_SLAVE_ADDR); + lPrintf(LOG_DEBUG+1, ">> NetFn : %02x", req->msg.netfn); + lPrintf(LOG_DEBUG+1, ">> Rs LUN : %01x", 0); + lPrintf(LOG_DEBUG+1, ">> Rq Addr : %02x", IPMI_REMOTE_SWID); + lPrintf(LOG_DEBUG+1, ">> Rq Seq : %02x", entry->rq_seq); + lPrintf(LOG_DEBUG+1, ">> Rq Lun : %01x", 0); + lPrintf(LOG_DEBUG+1, ">> Command : %02x", req->msg.cmd); + + /* message data */ + if (req->msg.data_len) { + memcpy(msg+len, req->msg.data, req->msg.data_len); + len += req->msg.data_len; + } + + /* second checksum */ + tmp = len - cs; + msg[len++] = intf->helper->ipmi_csum(msg+cs, tmp); + + entry->msg_len = len; + entry->msg_data = msg; + + return entry; +} + + + +/* + * is_sol_packet + */ +int LANPlus::is_sol_packet(struct ipmi_rs * rsp) +{ + return (rsp && + (rsp->session.authtype == IPMI_SESSION_AUTHTYPE_RMCP_PLUS) && + (rsp->session.payloadtype == IPMI_PAYLOAD_TYPE_SOL)); +} + + + +/* + * sol_response_acks_packet + */ +int +LANPlus::sol_response_acks_packet( + struct ipmi_rs * rsp, + struct ipmi_v2_payload * payload) +{ + return (is_sol_packet(rsp) && + payload && + (payload->payload_type == IPMI_PAYLOAD_TYPE_SOL) && + (rsp->payload.sol_packet.acked_packet_number == + payload->payload.sol_packet.packet_sequence_number)); +} + + + +/* + * ipmi_lanplus_send_payload + * + */ +struct ipmi_rs *LANPlus::ipmi_send_payload( + struct ipmi_v2_payload * payload) +{ + struct ipmi_rs * rsp = NULL; + uint8_t * msg_data = NULL; + int msg_length; + ipmi_session<LANPlus> * session = intf->session; + ipmi_rq_entry<LANPlus> * entry = NULL; + int ntry = 0; + int xmit = 1; + time_t ltime; + uint32_t saved_timeout; + + if (!intf->opened && intf->ipmi_open() < 0) + return NULL; + + /* + * The session timeout is initialized in the above interface open, + * so it will only be valid after the open completes. + */ + saved_timeout = session->timeout; + while (ntry < intf->session->retry) { + //ltime = time(NULL); + + if (xmit) { + ltime = time(NULL); + + if (payload->payload_type == IPMI_PAYLOAD_TYPE_IPMI) + { + /* + * Build an IPMI v1.5 or v2 command + */ + struct ipmi_rq * ipmi_request = payload->payload.ipmi_request.request; + + lPrintf(LOG_DEBUG, ""); + lPrintf(LOG_DEBUG, ">> Sending IPMI command payload"); + lPrintf(LOG_DEBUG, ">> netfn : 0x%02x", ipmi_request->msg.netfn); + lPrintf(LOG_DEBUG, ">> command : 0x%02x", ipmi_request->msg.cmd); + + if (verbose > 1) + { + uint16_t i; + fprintf(stderr, ">> data : "); + for (i = 0; i < ipmi_request->msg.data_len; ++i) + fprintf(stderr, "0x%02x ", ipmi_request->msg.data[i]); + fprintf(stderr, "\n\n"); + } + + + /* + * If we are presession, and the command is GET CHANNEL AUTHENTICATION + * CAPABILITIES, we will build the command in v1.5 format. This is so + * that we can ask any server whether it supports IPMI v2 / RMCP+ + * before we attempt to open a v2.x session. + */ + if ((ipmi_request->msg.netfn == IPMI_NETFN_APP) && + (ipmi_request->msg.cmd == IPMI_GET_CHANNEL_AUTH_CAP) && + (session->v2_data.bmc_id == 0)) // jme - check + { + lPrintf(LOG_DEBUG+1, "BUILDING A v1.5 COMMAND"); + entry = ipmi_build_v15_ipmi_cmd( ipmi_request); + } + else + { + int isRetry = ( ntry > 0 ? 1 : 0 ); + + lPrintf(LOG_DEBUG+1, "BUILDING A v2 COMMAND"); + entry = ipmi_build_v2x_ipmi_cmd( ipmi_request, isRetry); + } + + if (entry == NULL) { + lPrintf(LOG_ERR, "Aborting send command, unable to build"); + return NULL; + } + + msg_data = entry->msg_data; + msg_length = entry->msg_len; + } + + else if (payload->payload_type == IPMI_PAYLOAD_TYPE_RMCP_OPEN_REQUEST) + { + lPrintf(LOG_DEBUG, ">> SENDING AN OPEN SESSION REQUEST\n"); + assert(session->v2_data.session_state == LANPLUS_STATE_PRESESSION + || session->v2_data.session_state == LANPLUS_STATE_OPEN_SESSION_SENT); + + ipmi_build_v2x_msg(intf, /* in */ + payload, /* in */ + &msg_length, /* out */ + &msg_data, /* out */ + 0); /* irrelevant for this msg*/ + + } + + else if (payload->payload_type == IPMI_PAYLOAD_TYPE_RAKP_1) + { + lPrintf(LOG_DEBUG, ">> SENDING A RAKP 1 MESSAGE\n"); + assert(session->v2_data.session_state == + LANPLUS_STATE_OPEN_SESSION_RECEIEVED); + + ipmi_build_v2x_msg(intf, /* in */ + payload, /* in */ + &msg_length, /* out */ + &msg_data, /* out */ + 0); /* irrelevant for this msg*/ + + } + + else if (payload->payload_type == IPMI_PAYLOAD_TYPE_RAKP_3) + { + lPrintf(LOG_DEBUG, ">> SENDING A RAKP 3 MESSAGE\n"); + assert(session->v2_data.session_state == + LANPLUS_STATE_RAKP_2_RECEIVED); + + ipmi_build_v2x_msg(intf, /* in */ + payload, /* in */ + &msg_length, /* out */ + &msg_data, /* out */ + 0); /* irrelevant for this msg*/ + + } + + else if (payload->payload_type == IPMI_PAYLOAD_TYPE_SOL) + { + lPrintf(LOG_DEBUG, ">> SENDING A SOL MESSAGE\n"); + assert(session->v2_data.session_state == LANPLUS_STATE_ACTIVE); + + ipmi_build_v2x_msg(intf, /* in */ + payload, /* in */ + &msg_length, /* out */ + &msg_data, /* out */ + 0); /* irrelevant for this msg*/ + } + + else + { + lPrintf(LOG_ERR, "Payload type 0x%0x is unsupported!", + payload->payload_type); + assert(0); + } + + + if (ipmi_send_packet( msg_data, msg_length) < 0) { + lPrintf(LOG_ERR, "IPMI LAN send command failed"); + return NULL; + } + } + + /* if we are set to noanswer we do not expect response */ + if (intf->noanswer) + break; + + usleep(100); /* Not sure what this is for */ + + /* Remember our connection state */ + switch (payload->payload_type) + { + case IPMI_PAYLOAD_TYPE_RMCP_OPEN_REQUEST: + session->v2_data.session_state = LANPLUS_STATE_OPEN_SESSION_SENT; + /* not retryable for timeouts, force no retry */ + ntry = intf->session->retry; + break; + case IPMI_PAYLOAD_TYPE_RAKP_1: + session->v2_data.session_state = LANPLUS_STATE_RAKP_1_SENT; + /* not retryable for timeouts, force no retry */ + ntry = intf->session->retry; + break; + case IPMI_PAYLOAD_TYPE_RAKP_3: + /* not retryable for timeouts, force no retry */ + ntry = intf->session->retry; + session->v2_data.session_state = LANPLUS_STATE_RAKP_3_SENT; + break; + } + + + /* + * Special case for SOL outbound packets. + */ + if (payload->payload_type == IPMI_PAYLOAD_TYPE_SOL) + { + if (! payload->payload.sol_packet.packet_sequence_number) + { + /* We're just sending an ACK. No need to retry. */ + break; + } + + + rsp = ipmi_recv_sol(); /* Grab the next packet */ + + if (!is_sol_packet(rsp)) { + break; + } + + if (sol_response_acks_packet(rsp, payload)) + break; + + else if (is_sol_packet(rsp) && rsp->data_len) + { + /* + * We're still waiting for our ACK, but we more data from + * the BMC + */ + intf->session->sol_data.sol_input_handler(rsp); + /* In order to avoid duplicate output, just set data_len to 0 */ + rsp->data_len = 0; + break; + } + } + + + /* Non-SOL processing */ + else + { + rsp = ipmi_poll_recv(); + + /* Duplicate Request ccode most likely indicates a response to + a previous retry. Ignore and keep polling. */ + while ((rsp != NULL) && (rsp->ccode == 0xcf)) + { + rsp = NULL; + rsp = ipmi_poll_recv(); + } + + if (rsp) + break; + /* This payload type is retryable for timeouts. */ + if ((payload->payload_type == IPMI_PAYLOAD_TYPE_IPMI) && entry) { + ipmi_req_remove_entry( entry->rq_seq, entry->req.msg.cmd); + } + } + + /* only timeout if time exceeds the timeout value */ + xmit = ((time(NULL) - ltime) >= session->timeout); + + usleep(5000); + + if (xmit) { + /* increment session timeout by 1 second each retry */ + session->timeout++; + } + + ntry++; + } + session->timeout = saved_timeout; + + /* IPMI messages are deleted under ipmi_lan_poll_recv() */ + switch (payload->payload_type) { + case IPMI_PAYLOAD_TYPE_RMCP_OPEN_REQUEST: + case IPMI_PAYLOAD_TYPE_RAKP_1: + case IPMI_PAYLOAD_TYPE_RAKP_3: + case IPMI_PAYLOAD_TYPE_SOL: + free(msg_data); + msg_data = NULL; + break; + } + + return rsp; +} + + + +/* + * is_sol_partial_ack + * + * Determine if the response is a partial ACK/NACK that indicates + * we need to resend part of our packet. + * + * returns the number of characters we need to resend, or + * 0 if this isn't an ACK or we don't need to resend anything + */ +int LANPlus::is_sol_partial_ack( + struct ipmi_v2_payload * v2_payload, + struct ipmi_rs * rs) +{ + int chars_to_resend = 0; + + if (v2_payload && + rs && + is_sol_packet(rs) && + sol_response_acks_packet(rs, v2_payload) && + (rs->payload.sol_packet.accepted_character_count < + v2_payload->payload.sol_packet.character_count)) + { + if (oemO->ipmi_oem_active( "intelplus") && + rs->payload.sol_packet.accepted_character_count == 0) + return 0; + + chars_to_resend = + v2_payload->payload.sol_packet.character_count - + rs->payload.sol_packet.accepted_character_count; + } + + return chars_to_resend; +} + + + +/* + * set_sol_packet_sequence_number + */ +void LANPlus::set_sol_packet_sequence_number( + struct ipmi_v2_payload * v2_payload) +{ + /* Keep our sequence number sane */ + if (intf->session->sol_data.sequence_number > 0x0F) + intf->session->sol_data.sequence_number = 1; + + v2_payload->payload.sol_packet.packet_sequence_number = + intf->session->sol_data.sequence_number++; +} + + + +/* + * ipmi_lanplus_send_sol + * + * Sends a SOL packet.. We handle partial ACK/NACKs from the BMC here. + * + * Returns a pointer to the SOL ACK we received, or + * 0 on failure + * + */ +struct ipmi_rs *LANPlus::ipmi_send_sol( + struct ipmi_v2_payload * v2_payload) +{ + struct ipmi_rs * rs; + + /* + * chars_to_resend indicates either that we got a NACK telling us + * that we need to resend some part of our data. + */ + int chars_to_resend = 0; + + v2_payload->payload_type = IPMI_PAYLOAD_TYPE_SOL; + + /* + * Payload length is just the length of the character + * data here. + */ + v2_payload->payload_length = v2_payload->payload.sol_packet.character_count; + + v2_payload->payload.sol_packet.acked_packet_number = 0; /* NA */ + + set_sol_packet_sequence_number( v2_payload); + + v2_payload->payload.sol_packet.accepted_character_count = 0; /* NA */ + + rs = ipmi_send_payload( v2_payload); + + /* Determine if we need to resend some of our data */ + chars_to_resend = is_sol_partial_ack( v2_payload, rs); + + while (rs && !rs->payload.sol_packet.transfer_unavailable && + !rs->payload.sol_packet.is_nack && + chars_to_resend) + { + /* + * We first need to handle any new data we might have + * received in our NACK + */ + if (rs->data_len) + intf->session->sol_data.sol_input_handler(rs); + + set_sol_packet_sequence_number( v2_payload); + + /* Just send the required data */ + memmove(v2_payload->payload.sol_packet.data, + v2_payload->payload.sol_packet.data + + rs->payload.sol_packet.accepted_character_count, + chars_to_resend); + + v2_payload->payload.sol_packet.character_count = chars_to_resend; + + v2_payload->payload_length = v2_payload->payload.sol_packet.character_count; + + rs = ipmi_send_payload( v2_payload); + + chars_to_resend = is_sol_partial_ack( v2_payload, rs); + } + + return rs; +} + + + +/* + * check_sol_packet_for_new_data + * + * Determine whether the SOL packet has already been seen + * and whether the packet has new data for us. + * + * This function has the side effect of removing an previously + * seen data, and moving new data to the front. + * + * It also "Remembers" the data so we don't get repeats. + * + * returns the number of new bytes in the SOL packet + */ +int LANPlus::check_sol_packet_for_new_data( + struct ipmi_rs *rsp) +{ + uint8_t last_received_sequence_number = 0; + uint8_t last_received_byte_count = 0; + int new_data_size = 0; + + + if (rsp && + (rsp->session.authtype == IPMI_SESSION_AUTHTYPE_RMCP_PLUS) && + (rsp->session.payloadtype == IPMI_PAYLOAD_TYPE_SOL)) + { + /* Store the data length before we mod it */ + uint8_t unaltered_data_len = rsp->data_len; + + if (rsp->payload.sol_packet.packet_sequence_number == + last_received_sequence_number) + { + + /* + * This is the same as the last packet, but may include + * extra data + */ + new_data_size = rsp->data_len - last_received_byte_count; + + if (new_data_size > 0) + { + /* We have more data to process */ + memmove(rsp->data, + rsp->data + + rsp->data_len - new_data_size, + new_data_size); + } + + rsp->data_len = new_data_size; + } + + + /* + *Rember the data for next round + */ + if (rsp->payload.sol_packet.packet_sequence_number) + { + last_received_sequence_number = + rsp->payload.sol_packet.packet_sequence_number; + + last_received_byte_count = unaltered_data_len; + } + } + + + return new_data_size; +} + + + +/* + * ack_sol_packet + * + * Provided the specified packet looks reasonable, ACK it. + */ +void LANPlus::ack_sol_packet( + struct ipmi_rs * rsp) +{ + if (rsp && + (rsp->session.authtype == IPMI_SESSION_AUTHTYPE_RMCP_PLUS) && + (rsp->session.payloadtype == IPMI_PAYLOAD_TYPE_SOL) && + (rsp->payload.sol_packet.packet_sequence_number)) + { + struct ipmi_v2_payload ack; + + memset(&ack, 0, sizeof(struct ipmi_v2_payload)); + + ack.payload_type = IPMI_PAYLOAD_TYPE_SOL; + + /* + * Payload length is just the length of the character + * data here. + */ + ack.payload_length = 0; + + /* ACK packets have sequence numbers of 0 */ + ack.payload.sol_packet.packet_sequence_number = 0; + + ack.payload.sol_packet.acked_packet_number = + rsp->payload.sol_packet.packet_sequence_number; + + ack.payload.sol_packet.accepted_character_count = rsp->data_len; + + ipmi_send_payload( &ack); + } +} + + + +/* + * ipmi_lanplus_recv_sol + * + * Receive a SOL packet and send an ACK in response. + * + */ +struct ipmi_rs *LANPlus::ipmi_recv_sol() +{ + struct ipmi_rs * rsp = ipmi_poll_recv(); + + if (rsp && rsp->session.authtype != 0) + { + ack_sol_packet( rsp); + + /* + * Remembers the data sent, and alters the data to just + * include the new stuff. + */ + check_sol_packet_for_new_data( rsp); + } + return rsp; +} + + + +/** + * ipmi_lanplus_send_ipmi_cmd + * + * Build a payload request and dispatch it. + */ +struct ipmi_rs *LANPlus::ipmi_send_cmd( +// struct ipmi_intf * intf, + struct ipmi_rq * req, + struct ipmi_rs *rs) +{ + struct ipmi_v2_payload v2_payload; + + v2_payload.payload_type = IPMI_PAYLOAD_TYPE_IPMI; + v2_payload.payload.ipmi_request.request = req; + + rs=ipmi_send_payload( &v2_payload); + return rs; +} + + +/* + * ipmi_get_auth_capabilities_cmd + * + * This command may have to be sent twice. We first ask for the + * authentication capabilities with the "request IPMI v2 data bit" + * set. If this fails, we send the same command without that bit + * set. + * + * param intf is the initialized (but possibly) pre-session interface + * on which we will send the command + * param auth_cap [out] will be initialized to hold the Get Channel + * Authentication Capabilities return data on success. Its + * contents will be undefined on error. + * + * returns 0 on success + * non-zero if we were unable to contact the BMC, or we cannot + * get a successful response + * + */ +int +LANPlus::ipmi_get_auth_capabilities_cmd( + struct get_channel_auth_cap_rsp * auth_cap) +{ + struct ipmi_rs * rsp; + struct ipmi_rq req; + uint8_t msg_data[2]; + uint8_t backupBridgePossible; + + backupBridgePossible = bridgePossible; + + bridgePossible = 0; + + msg_data[0] = IPMI_LAN_CHANNEL_E | 0x80; // Ask for IPMI v2 data as well + msg_data[1] = intf->session->privlvl; + req.zero(); +// memset(&req, 0, sizeof(req)); + req.msg.netfn = IPMI_NETFN_APP; // 0x06 + req.msg.cmd = IPMI_GET_CHANNEL_AUTH_CAP; // 0x38 + req.msg.data = msg_data; + req.msg.data_len = 2; + + rsp = intf->sendrecv( &req); + + if (rsp == NULL || rsp->ccode > 0) { + /* + * It's very possible that this failed because we asked for IPMI + * v2 data. Ask again, without requesting IPMI v2 data. + */ + msg_data[0] &= 0x7F; + + rsp = intf->sendrecv( &req); + + if (rsp == NULL) { + lPrintf(LOG_INFO, "Get Auth Capabilities error"); + return 1; + } + if (rsp->ccode > 0) { + lPrintf(LOG_INFO, "Get Auth Capabilities error: %s", + intf->helper->val2str(rsp->ccode, completion_code_vals)); + return 1; + } + } + + + memcpy(auth_cap, + rsp->data, + sizeof(struct get_channel_auth_cap_rsp)); + + bridgePossible = backupBridgePossible; + + return 0; +} + + + +int LANPlus::ipmi_close_session_cmd() +{ + struct ipmi_rs * rsp; + struct ipmi_rq req; + uint8_t msg_data[4]; + uint32_t bmc_session_lsbf; + uint8_t backupBridgePossible; + + if (intf->session == NULL + || intf->session->v2_data.session_state != LANPLUS_STATE_ACTIVE) + return -1; + + backupBridgePossible = bridgePossible; + + intf->target_addr = IPMI_BMC_SLAVE_ADDR; + bridgePossible = 0; + + bmc_session_lsbf = intf->session->v2_data.bmc_id; +#if WORDS_BIGENDIAN + bmc_session_lsbf = BSWAP_32(bmc_session_lsbf); +#endif + + memcpy(&msg_data, &bmc_session_lsbf, 4); + req.zero(); +// memset(&req, 0, sizeof(req)); + req.msg.netfn = IPMI_NETFN_APP; + req.msg.cmd = 0x3c; + req.msg.data = msg_data; + req.msg.data_len = 4; + + rsp = intf->sendrecv( &req); + if (rsp == NULL) { + /* Looks like the session was closed */ + lPrintf(LOG_ERR, "Close Session command failed"); + return -1; + } + if (verbose > 2) + intf->helper->printbuf(rsp->data, rsp->data_len, "close_session"); + + if (rsp->ccode == 0x87) { + lPrintf(LOG_ERR, "Failed to Close Session: invalid " + "session ID %08lx", + (long)intf->session->v2_data.bmc_id); + return -1; + } + if (rsp->ccode > 0) { + lPrintf(LOG_ERR, "Close Session command failed: %s", + intf->helper->val2str(rsp->ccode, completion_code_vals)); + return -1; + } + + lPrintf(LOG_DEBUG, "Closed Session %08lx\n", + (long)intf->session->v2_data.bmc_id); + + bridgePossible = backupBridgePossible; + + return 0; +} + + + +/* + * ipmi_lanplus_open_session + * + * Build and send the open session command. See section 13.17 of the IPMI + * v2 specification for details. + */ +int LANPlus::ipmi_open_session() +{ + struct ipmi_v2_payload v2_payload; + ipmi_session<LANPlus> * session = intf->session; + uint8_t * msg; + struct ipmi_rs * rsp; + /* 0 = success, 1 = error, 2 = timeout */ + int rc = 0; + + + /* + * Build an Open Session Request Payload + */ + msg = (uint8_t*)malloc(IPMI_OPEN_SESSION_REQUEST_SIZE); + if (msg == NULL) { + lPrintf(LOG_ERR, "ipmitool: malloc failure"); + return 1; + } + + memset(msg, 0, IPMI_OPEN_SESSION_REQUEST_SIZE); + + msg[0] = 0; /* Message tag */ + if (oemO->ipmi_oem_active( "intelplus") || intf->session->privlvl != IPMI_SESSION_PRIV_ADMIN) + msg[1] = intf->session->privlvl; + else + msg[1] = 0; /* Give us highest privlg level based on supported algorithms */ + msg[2] = 0; /* reserved */ + msg[3] = 0; /* reserved */ + + /* Choose our session ID for easy recognition in the packet dump */ + session->v2_data.console_id = 0xA0A2A3A4; + msg[4] = session->v2_data.console_id & 0xff; + msg[5] = (session->v2_data.console_id >> 8) & 0xff; + msg[6] = (session->v2_data.console_id >> 16) & 0xff; + msg[7] = (session->v2_data.console_id >> 24) & 0xff; + + + if (lanplus_get_requested_ciphers(intf->session->cipher_suite_id, + &(session->v2_data.requested_auth_alg), + &(session->v2_data.requested_integrity_alg), + &(session->v2_data.requested_crypt_alg))) + { + lPrintf(LOG_WARNING, "Unsupported cipher suite ID : %d\n", + intf->session->cipher_suite_id); + free(msg); + msg = NULL; + return 1; + } + + + /* + * Authentication payload + */ + msg[8] = 0; /* specifies authentication payload */ + msg[9] = 0; /* reserved */ + msg[10] = 0; /* reserved */ + msg[11] = 8; /* payload length */ + msg[12] = session->v2_data.requested_auth_alg; + msg[13] = 0; /* reserved */ + msg[14] = 0; /* reserved */ + msg[15] = 0; /* reserved */ + + /* + * Integrity payload + */ + msg[16] = 1; /* specifies integrity payload */ + msg[17] = 0; /* reserved */ + msg[18] = 0; /* reserved */ + msg[19] = 8; /* payload length */ + msg[20] = session->v2_data.requested_integrity_alg; + msg[21] = 0; /* reserved */ + msg[22] = 0; /* reserved */ + msg[23] = 0; /* reserved */ + + /* + * Confidentiality/Encryption payload + */ + msg[24] = 2; /* specifies confidentiality payload */ + msg[25] = 0; /* reserved */ + msg[26] = 0; /* reserved */ + msg[27] = 8; /* payload length */ + msg[28] = session->v2_data.requested_crypt_alg; + msg[29] = 0; /* reserved */ + msg[30] = 0; /* reserved */ + msg[31] = 0; /* reserved */ + + + v2_payload.payload_type = IPMI_PAYLOAD_TYPE_RMCP_OPEN_REQUEST; + v2_payload.payload_length = IPMI_OPEN_SESSION_REQUEST_SIZE; + v2_payload.payload.open_session_request.request = msg; + + rsp = ipmi_send_payload( &v2_payload); + + free(msg); + msg = NULL; + if (rsp == NULL ) { + lPrintf(LOG_DEBUG, "Timeout in open session response message."); + return 2; + } + if (verbose) + lanplus_dump_open_session_response(rsp); + + if (rsp->payload.open_session_response.rakp_return_code != + IPMI_RAKP_STATUS_NO_ERRORS) + { + lPrintf(LOG_WARNING, "Error in open session response message : %s\n", + intf->helper->val2str(rsp->payload.open_session_response.rakp_return_code, + ipmi_rakp_return_codes)); + return 1; + } + else + { + if (rsp->payload.open_session_response.console_id != + session->v2_data.console_id) { + lPrintf(LOG_WARNING, "Warning: Console session ID is not " + "what we requested"); + } + + session->v2_data.max_priv_level = + rsp->payload.open_session_response.max_priv_level; + session->v2_data.bmc_id = + rsp->payload.open_session_response.bmc_id; + session->v2_data.auth_alg = + rsp->payload.open_session_response.auth_alg; + session->v2_data.integrity_alg = + rsp->payload.open_session_response.integrity_alg; + session->v2_data.crypt_alg = + rsp->payload.open_session_response.crypt_alg; + session->v2_data.session_state = + LANPLUS_STATE_OPEN_SESSION_RECEIEVED; + + + /* + * Verify that we have agreed on a cipher suite + */ + if (rsp->payload.open_session_response.auth_alg != + session->v2_data.requested_auth_alg) + { + lPrintf(LOG_WARNING, "Authentication algorithm 0x%02x is " + "not what we requested 0x%02x\n", + rsp->payload.open_session_response.auth_alg, + session->v2_data.requested_auth_alg); + rc = 1; + } + else if (rsp->payload.open_session_response.integrity_alg != + session->v2_data.requested_integrity_alg) + { + lPrintf(LOG_WARNING, "Integrity algorithm 0x%02x is " + "not what we requested 0x%02x\n", + rsp->payload.open_session_response.integrity_alg, + session->v2_data.requested_integrity_alg); + rc = 1; + } + else if (rsp->payload.open_session_response.crypt_alg != + session->v2_data.requested_crypt_alg) + { + lPrintf(LOG_WARNING, "Encryption algorithm 0x%02x is " + "not what we requested 0x%02x\n", + rsp->payload.open_session_response.crypt_alg, + session->v2_data.requested_crypt_alg); + rc = 1; + } + + } + + return rc; +} + + + +/* + * ipmi_lanplus_rakp1 + * + * Build and send the RAKP 1 message as part of the IPMI v2 / RMCP+ session + * negotiation protocol. We also read and validate the RAKP 2 message received + * from the BMC, here. See section 13.20 of the IPMI v2 specification for + * details. + * + * returns 0 on success + * 1 on failure + * + * Note that failure is only indicated if we have an internal error of + * some kind. If we actually get a RAKP 2 message in response to our + * RAKP 1 message, any errors will be stored in + * session->v2_data.rakp2_return_code and sent to the BMC in the RAKP + * 3 message. + */ +int +LANPlus::ipmi_rakp1() +{ + struct ipmi_v2_payload v2_payload; + ipmi_session<LANPlus> * session = intf->session; + uint8_t * msg; + struct ipmi_rs * rsp; + int rc = 0; /* 0 = success, 1 = error, 2 = timeout */ + + /* + * Build a RAKP 1 message + */ + msg = (uint8_t*)malloc(IPMI_RAKP1_MESSAGE_SIZE); + if (msg == NULL) { + lPrintf(LOG_ERR, "ipmitool: malloc failure"); + return 1; + } + memset(msg, 0, IPMI_RAKP1_MESSAGE_SIZE); + + + msg[0] = 0; /* Message tag */ + + msg[1] = 0; /* reserved */ + msg[2] = 0; /* reserved */ + msg[3] = 0; /* reserved */ + + /* BMC session ID */ + msg[4] = session->v2_data.bmc_id & 0xff; + msg[5] = (session->v2_data.bmc_id >> 8) & 0xff; + msg[6] = (session->v2_data.bmc_id >> 16) & 0xff; + msg[7] = (session->v2_data.bmc_id >> 24) & 0xff; + + + /* We need a 16 byte random number */ + if (lanplus_rand(session->v2_data.console_rand, 16)) + { + // ERROR; + lPrintf(LOG_ERR, "ERROR generating random number " + "in ipmi_lanplus_rakp1"); + free(msg); + msg = NULL; + return 1; + } + memcpy(msg + 8, session->v2_data.console_rand, 16); + #if WORDS_BIGENDIAN + lanplus_swap(msg + 8, 16); + #endif + + if (verbose > 1) + intf->helper->printbuf(session->v2_data.console_rand, 16, + ">> Console generated random number"); + + + /* + * Requested maximum privilege level. + */ + msg[24] = intf->session->privlvl | intf->session->lookupbit; + session->v2_data.requested_role = msg[24]; + msg[25] = 0; /* reserved */ + msg[26] = 0; /* reserved */ + + + /* Username specification */ + msg[27] = strlen((const char *)intf->session->username); + if (msg[27] > IPMI_MAX_USER_NAME_LENGTH) + { + lPrintf(LOG_ERR, "ERROR: user name too long. " + "(Exceeds %d characters)", + IPMI_MAX_USER_NAME_LENGTH); + free(msg); + msg = NULL; + return 1; + } + memcpy(msg + 28, intf->session->username, msg[27]); + + v2_payload.payload_type = IPMI_PAYLOAD_TYPE_RAKP_1; + if (oemO->ipmi_oem_active( "i82571spt")) { + /* + * The IPMI v2.0 spec hints on that all user name bytes + * must be occupied (29:44). The Intel 82571 GbE refuses + * to establish a session if this field is shorter. + */ + v2_payload.payload_length = IPMI_RAKP1_MESSAGE_SIZE; + } else { + v2_payload.payload_length = + IPMI_RAKP1_MESSAGE_SIZE - (16 - msg[27]); + } + v2_payload.payload.rakp_1_message.message = msg; + + rsp = ipmi_send_payload( &v2_payload); + + free(msg); + msg = NULL; + + if (rsp == NULL) + { + lPrintf(LOG_WARNING, "> Error: no response from RAKP 1 message"); + return 2; + } + + session->v2_data.session_state = LANPLUS_STATE_RAKP_2_RECEIVED; + + if (verbose) + lanplus_dump_rakp2_message(rsp, session->v2_data.auth_alg); + + + + if (rsp->payload.rakp2_message.rakp_return_code != IPMI_RAKP_STATUS_NO_ERRORS) + { + lPrintf(LOG_INFO, "RAKP 2 message indicates an error : %s", + intf->helper->val2str(rsp->payload.rakp2_message.rakp_return_code, + ipmi_rakp_return_codes)); + rc = 1; + } + + else + { + memcpy(session->v2_data.bmc_rand, rsp->payload.rakp2_message.bmc_rand, 16); + memcpy(session->v2_data.bmc_guid, rsp->payload.rakp2_message.bmc_guid, 16); + + if (verbose > 2) + intf->helper->printbuf(session->v2_data.bmc_rand, 16, "bmc_rand"); + + /* + * It is at this point that we have to decode the random number and determine + * whether the BMC has authenticated. + */ + if (!Crypt->rakp2_hmac_matches(session, + rsp->payload.rakp2_message.key_exchange_auth_code, + intf)) + { + /* Error */ + lPrintf(LOG_INFO, "> RAKP 2 HMAC is invalid"); + session->v2_data.rakp2_return_code = IPMI_RAKP_STATUS_INVALID_INTEGRITY_CHECK_VALUE; + rc = 1; + } + else + { + /* Success */ + session->v2_data.rakp2_return_code = IPMI_RAKP_STATUS_NO_ERRORS; + } + } + + return rc; +} + + + +/* + * ipmi_lanplus_rakp3 + * + * Build and send the RAKP 3 message as part of the IPMI v2 / RMCP+ session + * negotiation protocol. We also read and validate the RAKP 4 message received + * from the BMC, here. See section 13.20 of the IPMI v2 specification for + * details. + * + * If the RAKP 2 return code is not IPMI_RAKP_STATUS_NO_ERRORS, we will + * exit with an error code immediately after sendint the RAKP 3 message. + * + * param intf is the intf that holds all the state we are concerned with + * + * returns 0 on success + * 1 on failure + */ +int LANPlus::ipmi_rakp3() +{ + struct ipmi_v2_payload v2_payload; + ipmi_session<LANPlus>* session = intf->session; + uint8_t * msg; + struct ipmi_rs * rsp; + + assert(session->v2_data.session_state == LANPLUS_STATE_RAKP_2_RECEIVED); + + /* + * Build a RAKP 3 message + */ + msg = (uint8_t*)malloc(IPMI_RAKP3_MESSAGE_MAX_SIZE); + if (msg == NULL) { + lPrintf(LOG_ERR, "ipmitool: malloc failure"); + return 1; + } + memset(msg, 0, IPMI_RAKP3_MESSAGE_MAX_SIZE); + + + msg[0] = 0; /* Message tag */ + msg[1] = session->v2_data.rakp2_return_code; + + msg[2] = 0; /* reserved */ + msg[3] = 0; /* reserved */ + + /* BMC session ID */ + msg[4] = session->v2_data.bmc_id & 0xff; + msg[5] = (session->v2_data.bmc_id >> 8) & 0xff; + msg[6] = (session->v2_data.bmc_id >> 16) & 0xff; + msg[7] = (session->v2_data.bmc_id >> 24) & 0xff; + + v2_payload.payload_type = IPMI_PAYLOAD_TYPE_RAKP_3; + v2_payload.payload_length = 8; + v2_payload.payload.rakp_3_message.message = msg; + + /* + * If the rakp2 return code indicates and error, we don't have to + * generate an authcode or session integrity key. In that case, we + * are simply sending a RAKP 3 message to indicate to the BMC that the + * RAKP 2 message caused an error. + */ + if (session->v2_data.rakp2_return_code == IPMI_RAKP_STATUS_NO_ERRORS) + { + uint32_t auth_length; + + if (Crypt->generate_rakp3_authcode(msg + 8, session, &auth_length, intf)) + { + /* Error */ + lPrintf(LOG_INFO, "> Error generating RAKP 3 authcode"); + free(msg); + msg = NULL; + return 1; + } + else + { + /* Success */ + v2_payload.payload_length += auth_length; + } + + /* Generate our Session Integrity Key, K1, and K2 */ + if (Crypt->generate_sik(session, intf)) + { + /* Error */ + lPrintf(LOG_INFO, "> Error generating session integrity key"); + free(msg); + msg = NULL; + return 1; + } + else if (Crypt->generate_k1(session)) + { + /* Error */ + lPrintf(LOG_INFO, "> Error generating K1 key"); + free(msg); + msg = NULL; + return 1; + } + else if (Crypt->generate_k2(session)) + { + /* Error */ + lPrintf(LOG_INFO, "> Error generating K1 key"); + free(msg); + msg = NULL; + return 1; + } + } + + + rsp = ipmi_send_payload( &v2_payload); + + free(msg); + msg = NULL; + + if (session->v2_data.rakp2_return_code != IPMI_RAKP_STATUS_NO_ERRORS) + { + /* + * If the previous RAKP 2 message received was deemed erroneous, + * we have nothing else to do here. We only sent the RAKP 3 message + * to indicate to the BMC that the RAKP 2 message failed. + */ + return 1; + } + else if (rsp == NULL) + { + lPrintf(LOG_WARNING, "> Error: no response from RAKP 3 message"); + return 2; + } + + + /* + * We have a RAKP 4 message to chew on. + */ + if (verbose) + lanplus_dump_rakp4_message(rsp, session->v2_data.auth_alg); + + + if (rsp->payload.open_session_response.rakp_return_code != IPMI_RAKP_STATUS_NO_ERRORS) + { + lPrintf(LOG_INFO, "RAKP 4 message indicates an error : %s", + intf->helper->val2str(rsp->payload.rakp4_message.rakp_return_code, + ipmi_rakp_return_codes)); + return 1; + } + + else + { + /* Validate the authcode */ + if (Crypt->rakp4_hmac_matches(session, + rsp->payload.rakp4_message.integrity_check_value, + intf)) + { + /* Success */ + session->v2_data.session_state = LANPLUS_STATE_ACTIVE; + } + else + { + /* Error */ + lPrintf(LOG_INFO, "> RAKP 4 message has invalid integrity check value"); + return 1; + } + } + + intf->abort = 0; + return 0; +} + + + +/** + * ipmi_lan_close + */ +void LANPlus::ipmi_close() +{ + if (intf!=0) + { + if (!intf->abort && intf->session) + ipmi_close_session_cmd(); + + if (intf->fd >= 0) { + close(intf->fd); + intf->fd = -1; + } + + intf->ipmi_intf_session_cleanup(); + intf->opened = 0; + intf->manufacturer_id = IPMI_OEM_UNKNOWN; + intf = NULL; + } + ipmi_req_clear_entries(); +} + + + +int LANPlus::ipmi_set_session_privlvl_cmd() +{ + struct ipmi_rs * rsp; + struct ipmi_rq req; + uint8_t backupBridgePossible; + uint8_t privlvl = intf->session->privlvl; + + if (privlvl <= IPMI_SESSION_PRIV_USER) + return 0; /* no need to set higher */ + + backupBridgePossible = bridgePossible; + + bridgePossible = 0; + req.zero(); +// memset(&req, 0, sizeof(req)); + req.msg.netfn = IPMI_NETFN_APP; + req.msg.cmd = 0x3b; + req.msg.data = &privlvl; + req.msg.data_len = 1; + + rsp = intf->sendrecv( &req); + if (rsp == NULL) { + lPrintf(LOG_ERR, "Set Session Privilege Level to %s failed", + intf->helper->val2str(privlvl, ipmi_privlvl_vals)); + bridgePossible = backupBridgePossible; + return -1; + } + if (verbose > 2) + intf->helper->printbuf(rsp->data, rsp->data_len, "set_session_privlvl"); + + if (rsp->ccode > 0) { + lPrintf(LOG_ERR, "Set Session Privilege Level to %s failed: %s", + intf->helper->val2str(privlvl, ipmi_privlvl_vals), + intf->helper->val2str(rsp->ccode, completion_code_vals)); + bridgePossible = backupBridgePossible; + return -1; + } + + lPrintf(LOG_DEBUG, "Set Session Privilege Level to %s\n", + intf->helper->val2str(rsp->data[0], ipmi_privlvl_vals)); + + bridgePossible = backupBridgePossible; + + return 0; +} + +/** + * ipmi_lanplus_open + */ +int LANPlus::ipmi_open() +{ + int rc; + int retry; + struct get_channel_auth_cap_rsp auth_cap; +// struct ipmi_session_params *params; + ipmi_session<LANPlus> * session; + + if (!intf) + return -1; + + if (intf->opened) + return intf->fd; + if (intf->session == 0) + { + lPrintf(LOG_ERR, "LANPlus: Logic Error. No Session defined when calling ipmi_open"); + goto fail; + } + session = intf->session; + +// params = &intf->ssn_params; + + if (!session->port) + session->port = IPMI_LANPLUS_PORT; + if (!session->privlvl) + session->privlvl = IPMI_SESSION_PRIV_ADMIN; + if (!session->timeout) + session->timeout = IPMI_LAN_TIMEOUT; + if (!session->retry) + session->retry = IPMI_LAN_RETRY; + + if (session->hostname == NULL || strlen((const char *)session->hostname) == 0) { + lPrintf(LOG_ERR, "No hostname specified!"); + return -1; + } + + + if (intf->ipmi_intf_socket_connect() == -1) { + lPrintf(LOG_ERR, "Could not open socket!"); + goto fail; + } + + /* Setup our lanplus session state */ +// session->timeout = session->timeout; +// memcpy(&session->authcode, &session->authcode_set, sizeof(session->authcode)); + session->v2_data.auth_alg = IPMI_AUTH_RAKP_NONE; + session->v2_data.crypt_alg = IPMI_CRYPT_NONE; + session->sol_data.sequence_number = 1; + + intf->opened = 1; + intf->abort = 1; + rc = ipmiv2_ping(); + if (rc <= 0) + { + sessionsup_fail = SessSup_PingFail; + lPrintf(LOG_DEBUG, "Error: ipmi_lan_ping failed for %s. INTF:%p FD:%d",intf->session->hostname,intf,intf->fd); + goto fail; + } + /* + * + * Make sure the BMC supports IPMI v2 / RMCP+ + */ + if (!oemO->ipmi_oem_active( "i82571spt") && + ipmi_get_auth_capabilities_cmd( &auth_cap)) { + lPrintf(LOG_INFO, "Error issuing Get Channel " + "Authentication Capabilities request"); + goto fail; + } + + if (!oemO->ipmi_oem_active( "i82571spt") && ! auth_cap.v20_data_available) { + lPrintf(LOG_INFO, "This BMC does not support IPMI v2 / RMCP+"); + goto fail; + } + + /* + * If the open/rakp1/rakp3 sequence encounters a timeout, the whole sequence + * needs to restart. The individual messages are not individually retryable, + * as the session state is advancing. + */ + for (retry = 0; retry < IPMI_LAN_RETRY; retry++) { + session->v2_data.session_state = LANPLUS_STATE_PRESESSION; + /* + * Open session + */ + if ((rc = ipmi_open_session()) == 1) { + goto fail; + } + if (rc == 2) { + lPrintf(LOG_DEBUG, "Retry lanplus open session, %d", retry); + continue; + } + /* + * RAKP 1 + */ + if ((rc = ipmi_rakp1()) == 1) { + goto fail; + } + if (rc == 2) { + lPrintf(LOG_DEBUG, "Retry lanplus rakp1, %d", retry); + continue; + } + /* + * RAKP 3 + */ + if ((rc = ipmi_rakp3()) == 1) { + goto fail; + } + if (rc == 0) break; + lPrintf(LOG_DEBUG,"Retry lanplus rakp3, %d", retry); + } + + lPrintf(LOG_DEBUG, "IPMIv2 / RMCP+ SESSION OPENED SUCCESSFULLY\n"); + + intf->abort = 0; + + if (!oemO->ipmi_oem_active( "i82571spt")) { + rc = ipmi_set_session_privlvl_cmd(); + if (rc < 0) { + goto fail; + } + + /* automatically detect interface request and response sizes */ + hpm2_detect_max_payload_size<LANPlus>(intf); + } + + bridgePossible = 1; + + if (!oemO->ipmi_oem_active( "i82571spt")) { + intf->manufacturer_id = intf->helper->ipmi_get_oem(intf); + } + + return intf->fd; + + fail: + lPrintf(LOG_ERR, "Error: Unable to establish IPMI v2 / RMCP+ session to host %s",intf->session->hostname); + intf->ipmi_close(); + return -1; +} + + + +void LANPlus::test_crypt1(void) +{ + uint8_t key[] = + {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, + 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14}; + + uint16_t bytes_encrypted; + uint16_t bytes_decrypted; + uint8_t decrypt_buffer[1000]; + uint8_t encrypt_buffer[1000]; + + uint8_t data[] = + {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, + 0x11, 0x12}; + + intf->helper->printbuf(data, sizeof(data), "original data"); + + if (Crypt->encrypt_payload(IPMI_CRYPT_AES_CBC_128, + key, + data, + sizeof(data), + encrypt_buffer, + &bytes_encrypted)) + { + lPrintf(LOG_ERR, "Encrypt test failed"); + assert(0); + } + intf->helper->printbuf(encrypt_buffer, bytes_encrypted, "encrypted payload"); + + + if (Crypt->decrypt_payload(IPMI_CRYPT_AES_CBC_128, + key, + encrypt_buffer, + bytes_encrypted, + decrypt_buffer, + &bytes_decrypted)) + { + lPrintf(LOG_ERR, "Decrypt test failed\n"); + assert(0); + } + intf->helper->printbuf(decrypt_buffer, bytes_decrypted, "decrypted payload"); + + lPrintf(LOG_DEBUG, "\nDone testing the encrypt/decyrpt methods!\n"); + exit(0); +} + + + +void LANPlus::test_crypt2(void) +{ + uint8_t key[] = + {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, + 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14}; + uint8_t iv[] = + {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, + 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14}; + uint8_t data[8] = "1234567"; + + uint8_t encrypt_buffer[1000]; + uint8_t decrypt_buffer[1000]; + uint32_t bytes_encrypted; + uint32_t bytes_decrypted; + + intf->helper->printbuf((const uint8_t *)data, strlen((const char *)data), "input data"); + + encrypt_aes_cbc_128(iv, + key, + data, + strlen((const char *)data), + encrypt_buffer, + &bytes_encrypted); + intf->helper->printbuf((const uint8_t *)encrypt_buffer, bytes_encrypted, "encrypt_buffer"); + + decrypt_aes_cbc_128(iv, + key, + encrypt_buffer, + bytes_encrypted, + decrypt_buffer, + &bytes_decrypted); + intf->helper->printbuf((const uint8_t *)decrypt_buffer, bytes_decrypted, "decrypt_buffer"); + + lPrintf(LOG_INFO, "\nDone testing the encrypt/decyrpt methods!\n"); + exit(0); +} + + +/** + * send a get device id command to keep session active + */ +int LANPlus::ipmi_keepalive() +{ + struct ipmi_rs * rsp; + struct ipmi_rq req; + req.msg.netfn = IPMI_NETFN_APP; + req.msg.lun=0; + req.msg.cmd = 1; + req.msg.target_cmd=0; + req.msg.data_len=0; + req.msg.data =0; + + if (!intf->opened) + return 0; + + rsp = intf->sendrecv( &req); + while (rsp != NULL && is_sol_packet(rsp)) { + /* rsp was SOL data instead of our answer */ + /* since it didn't go through the sol recv, do sol recv stuff here */ + ack_sol_packet( rsp); + check_sol_packet_for_new_data( rsp); + if (rsp->data_len) + intf->session->sol_data.sol_input_handler(rsp); + rsp = ipmi_poll_recv(); + if (rsp == NULL) /* the get device id answer never got back, but retry mechanism was bypassed by SOL data */ + return 0; /* so get device id command never returned, the connection is still alive */ + } + + if (rsp == NULL) + return -1; + if (rsp->ccode > 0) + return -1; + + return 0; +} + + +/** + * ipmi_lanplus_setup + */ +int LANPlus::ipmi_setup() +{ + //test_crypt1(); + assert("ipmi_lanplus_setup"); + + if (seed_prng(16)) + return -1; + + /* setup default LAN maximum request and response sizes */ + intf->max_request_data_size = IPMI_LAN_MAX_REQUEST_SIZE; + intf->max_response_data_size = IPMI_LAN_MAX_RESPONSE_SIZE; + + return 0; +} + +void LANPlus::ipmi_set_max_rq_data_size( uint16_t size) +{ + if (intf->session->cipher_suite_id == 3) { + /* + * encrypted payload can only be multiple of 16 bytes + */ + size &= ~15; + + /* + * decrement payload size on confidentiality header size + * plus minimal confidentiality trailer size + */ + size -= (16 + 1); + } + + intf->max_request_data_size = size; +} + +void LANPlus::ipmi_set_max_rp_data_size(uint16_t size) +{ + if (intf->session->cipher_suite_id == 3) { + /* + * encrypted payload can only be multiple of 16 bytes + */ + size &= ~15; + + /* + * decrement payload size on confidentiality header size + * plus minimal confidentiality trailer size + */ + size -= (16 + 1); + } + + intf->max_response_data_size = size; +} diff --git a/Online/IPMI/src/NewLib/LANPlus.h b/Online/IPMI/src/NewLib/LANPlus.h new file mode 100644 index 0000000000000000000000000000000000000000..c76449d92bd465d1cd1437e1162b0dc0340ab332 --- /dev/null +++ b/Online/IPMI/src/NewLib/LANPlus.h @@ -0,0 +1,294 @@ +/* + * LANPlus.h + * + * Created on: Jul 14, 2021 + * Author: beat + */ + +#ifndef NEWLIB_LANPLUS_H_ +#define NEWLIB_LANPLUS_H_ + +#include "ipmi.h" +#include "lanplus_crypt.h" +//#include "lanplus/lanplus_crypt_impl.h" +//#include "lanplus/lanplus_dump.h" +//#include "lanplus/rmcp.h" +//#include "lanplus/asf.h" +//#include "ipmi_intf.h" +//#include "ipmi_session.h" +//#include "ipmi.h" +//#include "helper.h" +//#include "ipmi_constants.h" +//#include "ipmi_oem.h" +//#include "hpm2.h" +//#include "ipmi_sel.h" +#include "helper.h" +//#include "LANBase.h" +#include <stdio.h> +#include <string.h> +#include "ipmi_oem.h" +#define IPMI_LANPLUS_PORT 0x26f + +/* + * RAKP return codes. These values come from table 13-15 of the IPMI v2 + * specification. + */ +#define IPMI_RAKP_STATUS_NO_ERRORS 0x00 +#define IPMI_RAKP_STATUS_INSUFFICIENT_RESOURCES_FOR_SESSION 0x01 +#define IPMI_RAKP_STATUS_INVALID_SESSION_ID 0x02 +#define IPMI_RAKP_STATUS_INVALID_PAYLOAD_TYPE 0x03 +#define IPMI_RAKP_STATUS_INVALID_AUTHENTICATION_ALGORITHM 0x04 +#define IPMI_RAKP_STATUS_INVALID_INTEGRITTY_ALGORITHM 0x05 +#define IPMI_RAKP_STATUS_NO_MATCHING_AUTHENTICATION_PAYLOAD 0x06 +#define IPMI_RAKP_STATUS_NO_MATCHING_INTEGRITY_PAYLOAD 0x07 +#define IPMI_RAKP_STATUS_INACTIVE_SESSION_ID 0x08 +#define IPMI_RAKP_STATUS_INVALID_ROLE 0x09 +#define IPMI_RAKP_STATUS_UNAUTHORIZED_ROLE_REQUESTED 0x0A +#define IPMI_RAKP_STATUS_INSUFFICIENT_RESOURCES_FOR_ROLE 0x0B +#define IPMI_RAKP_STATUS_INVALID_NAME_LENGTH 0x0C +#define IPMI_RAKP_STATUS_UNAUTHORIZED_NAME 0x0D +#define IPMI_RAKP_STATUS_UNAUTHORIZED_GUID 0x0E +#define IPMI_RAKP_STATUS_INVALID_INTEGRITY_CHECK_VALUE 0x0F +#define IPMI_RAKP_STATUS_INVALID_CONFIDENTIALITY_ALGORITHM 0x10 +#define IPMI_RAKP_STATUS_NO_CIPHER_SUITE_MATCH 0x11 +#define IPMI_RAKP_STATUS_ILLEGAL_PARAMTER 0x12 + +#define IPMI_LAN_CHANNEL_1 0x07 +#define IPMI_LAN_CHANNEL_2 0x06 +#define IPMI_LAN_CHANNEL_E 0x0e + +#define IPMI_LAN_TIMEOUT 2 +#define IPMI_LAN_RETRY 4 + +#define IPMI_PRIV_CALLBACK 1 +#define IPMI_PRIV_USER 2 +#define IPMI_PRIV_OPERATOR 3 +#define IPMI_PRIV_ADMIN 4 +#define IPMI_PRIV_OEM 5 + +#define IPMI_CRYPT_AES_CBC_128_BLOCK_SIZE 0x10 + +/* Session message offsets, from table 13-8 of the v2 specification */ +#define IPMI_LANPLUS_OFFSET_AUTHTYPE 0x04 +#define IPMI_LANPLUS_OFFSET_PAYLOAD_TYPE 0x05 +#define IPMI_LANPLUS_OFFSET_SESSION_ID 0x06 +#define IPMI_LANPLUS_OFFSET_SEQUENCE_NUM 0x0A +#define IPMI_LANPLUS_OFFSET_PAYLOAD_SIZE 0x0E +#define IPMI_LANPLUS_OFFSET_PAYLOAD 0x10 + +#define IPMI_GET_CHANNEL_AUTH_CAP 0x38 + +/* + * TODO: these are wild guesses and should be checked + */ +#define IPMI_MAX_CONF_HEADER_SIZE 0x20 +#define IPMI_MAX_PAYLOAD_SIZE 0xFFFF /* Includes confidentiality header/trailer */ +#define IPMI_MAX_CONF_TRAILER_SIZE 0x20 +#define IPMI_MAX_INTEGRITY_PAD_SIZE IPMI_MAX_MD_SIZE +#define IPMI_MAX_AUTH_CODE_SIZE IPMI_MAX_MD_SIZE + +#define IPMI_REQUEST_MESSAGE_SIZE 0x07 +#define IPMI_MAX_MAC_SIZE IPMI_MAX_MD_SIZE /* The largest mac we ever expect to generate */ + +#define IPMI_SHA1_AUTHCODE_SIZE 12 +#define IPMI_HMAC_MD5_AUTHCODE_SIZE 16 +#define IPMI_MD5_AUTHCODE_SIZE 16 +#define IPMI_HMAC_SHA256_AUTHCODE_SIZE 16 + +#define IPMI_SHA_DIGEST_LENGTH 20 +#define IPMI_MD5_DIGEST_LENGTH 16 +#define IPMI_SHA256_DIGEST_LENGTH 32 + +/* + *This is accurate, as long as we're only passing 1 auth algorithm, + * one integrity algorithm, and 1 encyrption alogrithm + */ +#define IPMI_OPEN_SESSION_REQUEST_SIZE 32 +#define IPMI_RAKP1_MESSAGE_SIZE 44 +#define IPMI_RAKP3_MESSAGE_MAX_SIZE (8 + IPMI_MAX_MD_SIZE) + +#define IPMI_MAX_USER_NAME_LENGTH 16 +#if 0 +extern const struct valstr ipmi_privlvl_vals[]; +extern const struct valstr ipmi_authtype_vals[]; +#endif + +#define IPMI_LAN_MAX_REQUEST_SIZE 38 /* 45 - 7 */ +#define IPMI_LAN_MAX_RESPONSE_SIZE 34 /* 42 - 8 */ + + +extern int verbose; + +struct ipmi_rq; +const valstr ipmi_rakp_return_codes[] = { + + { IPMI_RAKP_STATUS_NO_ERRORS, "no errors" }, + { IPMI_RAKP_STATUS_INSUFFICIENT_RESOURCES_FOR_SESSION, "insufficient resources for session" }, + { IPMI_RAKP_STATUS_INVALID_SESSION_ID, "invalid session ID" }, + { IPMI_RAKP_STATUS_INVALID_PAYLOAD_TYPE, "invalid payload type" }, + { IPMI_RAKP_STATUS_INVALID_AUTHENTICATION_ALGORITHM, "invalid authentication algorithm" }, + { IPMI_RAKP_STATUS_INVALID_INTEGRITTY_ALGORITHM, "invalid integrity algorithm" }, + { IPMI_RAKP_STATUS_NO_MATCHING_AUTHENTICATION_PAYLOAD, "no matching authentication algorithm"}, + { IPMI_RAKP_STATUS_NO_MATCHING_INTEGRITY_PAYLOAD, "no matching integrity payload" }, + { IPMI_RAKP_STATUS_INACTIVE_SESSION_ID, "inactive session ID" }, + { IPMI_RAKP_STATUS_INVALID_ROLE, "invalid role" }, + { IPMI_RAKP_STATUS_UNAUTHORIZED_ROLE_REQUESTED, "unauthorized role requested" }, + { IPMI_RAKP_STATUS_INSUFFICIENT_RESOURCES_FOR_ROLE, "insufficient resources for role" }, + { IPMI_RAKP_STATUS_INVALID_NAME_LENGTH, "invalid name length" }, + { IPMI_RAKP_STATUS_UNAUTHORIZED_NAME, "unauthorized name" }, + { IPMI_RAKP_STATUS_UNAUTHORIZED_GUID, "unauthorized GUID" }, + { IPMI_RAKP_STATUS_INVALID_INTEGRITY_CHECK_VALUE, "invalid integrity check value" }, + { IPMI_RAKP_STATUS_INVALID_CONFIDENTIALITY_ALGORITHM, "invalid confidentiality algorithm" }, + { IPMI_RAKP_STATUS_NO_CIPHER_SUITE_MATCH, "no matching cipher suite" }, + { IPMI_RAKP_STATUS_ILLEGAL_PARAMTER, "illegal parameter" }, + { 0, 0 }, +}; +#include "auth.h" +#define IPMI_LAN_MAX_REQUEST_SIZE 38 /* 45 - 7 */ +#define IPMI_LAN_MAX_RESPONSE_SIZE 34 /* 42 - 8 */ + +const valstr ipmi_priv_levels[] = { + { IPMI_PRIV_CALLBACK, "callback" }, + { IPMI_PRIV_USER, "user" }, + { IPMI_PRIV_OPERATOR, "operator" }, + { IPMI_PRIV_ADMIN, "admin" }, + { IPMI_PRIV_OEM, "oem" }, + { 0, 0 }, +}; +template <class G> class ipmi_intf; + +class LANPlus +{ + public: + using ipmi_Intf = ipmi_intf<LANPlus>; + ipmi_Intf *intf; + ipmi_rq_entry<LANPlus> * ipmi_req_entries; + ipmi_rq_entry<LANPlus> * ipmi_req_entries_tail; + uint8_t bridgePossible = 0; + char name[16];//: "lan" + char desc[128];//("IPMI v1.5 LAN Interface"); + uint8_t bridge_possible; + ipmi_auth<LANPlus> *auth; + int sessionsup_fail; + ipmi_oem<LANPlus> *oemO; + struct ipmi_rs rsp; + LANPlus(ipmi_Intf *Intf) + { + this->intf = Intf; + strcpy(name, "LANPlus"); + strcpy(desc, "IPMI v2 LAN Interface"); + ipmi_req_entries = 0; + ipmi_req_entries_tail = 0; + bridge_possible = 0; + auth = new ipmi_auth<LANPlus>(); + sessionsup_fail = false; + oemO = new ipmi_oem<LANPlus>(intf); + Crypt = new LANPlusCrypt<LANPlus>(oemO); + } + ~LANPlus(); + LANPlusCrypt<LANPlus> *Crypt; + int ipmi_send_packet( uint8_t * data, int data_len); + int ipmi_open(); + int ipmi_setup(); + int ipmi_keepalive(); + void ipmi_set_max_rq_data_size( uint16_t size); + int ipmi_lan_send_packet( uint8_t * data, int data_len); + struct ipmi_rs * ipmi_recv_packet(); + struct ipmi_rs * ipmi_poll_recv(); + struct ipmi_rs * ipmi_send_cmd( struct ipmi_rq * req,struct ipmi_rs *); + struct ipmi_rs * ipmi_send_payload(struct ipmi_v2_payload * payload); + void getIpmiPayloadWireRep( + struct ipmi_v2_payload * payload, /* in */ + uint8_t * out, + struct ipmi_rq * req, + uint8_t rq_seq, + uint8_t curr_seq); + void getSolPayloadWireRep(ipmi_Intf * intf, + uint8_t * msg, + struct ipmi_v2_payload * payload); + void read_open_session_response(struct ipmi_rs * rsp, int offset); + void read_rakp2_message(struct ipmi_rs * rsp, int offset, uint8_t alg); + void read_rakp4_message(struct ipmi_rs * rsp, int offset, uint8_t alg); + void read_session_data(struct ipmi_rs * rsp, int * offset, ipmi_session<LANPlus> *s); + void read_session_data_v15(struct ipmi_rs * rsp, int * offset, ipmi_session<LANPlus> *s); + void read_session_data_v2x(struct ipmi_rs * rsp, int * offset, ipmi_session<LANPlus> *s); + void read_ipmi_response(struct ipmi_rs * rsp, int * offset); + void read_sol_packet(struct ipmi_rs * rsp, int * offset); + struct ipmi_rs * ipmi_recv_sol(); + struct ipmi_rs * ipmi_send_sol(struct ipmi_v2_payload * payload); + int check_sol_packet_for_new_data(struct ipmi_rs *rsp); + void ack_sol_packet(struct ipmi_rs * rsp); + void ipmi_lanp_set_max_rq_data_size( uint16_t size); + void ipmi_lanp_set_max_rp_data_size( uint16_t size); + int get_requested_ciphers(int cipher_suite_id, + uint8_t * auth_alg, + uint8_t * integrity_alg, + uint8_t * crypt_alg); + void lanplus_swap( + uint8_t * buffer, + int length); + void ipmi_build_v2x_msg(ipmi_Intf * intf, /* in */ + struct ipmi_v2_payload * payload, /* in */ + int * msg_len, /* out */ + uint8_t ** msg_data, /* out */ + uint8_t curr_seq); + ipmi_rq_entry<LANPlus> *ipmi_req_add_entry( struct ipmi_rq * req, uint8_t req_seq); + ipmi_rq_entry<LANPlus> *ipmi_req_lookup_entry(uint8_t seq, uint8_t cmd); + void ipmi_req_remove_entry(uint8_t seq, uint8_t cmd); + void ipmi_req_clear_entries(void); + int ipmi_handle_pong( struct ipmi_rs * rsp); + int ipmiv2_ping(); + struct ipmi_rs *ipmi_poll_single(); + ipmi_rq_entry<LANPlus> *ipmi_build_v2x_ipmi_cmd( + + struct ipmi_rq * req, + int isRetry); + ipmi_rq_entry<LANPlus> *ipmi_build_v15_ipmi_cmd( + + struct ipmi_rq * req); + int sol_response_acks_packet( + struct ipmi_rs * rsp, + struct ipmi_v2_payload * payload);; + + int is_sol_packet(struct ipmi_rs * rsp); + int is_sol_partial_ack( + struct ipmi_v2_payload * v2_payload, +#define IPMI_LAN_MAX_REQUEST_SIZE 38 /* 45 - 7 */ +#define IPMI_LAN_MAX_RESPONSE_SIZE 34 /* 42 - 8 */ + struct ipmi_rs * rs); + void ipmi_set_max_rp_data_size(uint16_t size); + void set_sol_packet_sequence_number( + + struct ipmi_v2_payload * v2_payload); + int ipmi_get_auth_capabilities_cmd(struct get_channel_auth_cap_rsp * auth_cap); + int ipmi_close_session_cmd(); + int ipmi_open_session(); + int ipmi_rakp1(); + int ipmi_rakp3(); + void ipmi_close(); + int ipmi_set_session_privlvl_cmd(); + void test_crypt1(void); + void test_crypt2(void); + int lanplus_get_requested_ciphers(int cipher_suite_id, + uint8_t * auth_alg, + uint8_t * integrity_alg, + uint8_t * crypt_alg); + int get_session_setup_code(){return sessionsup_fail;}; + private: +/* struct ipmi_intf ipmi_lanplus_intf = { + .name = "lanplus", + .desc = "IPMI v2.0 RMCP+ LAN Interface", + .setup = ipmi_lanplus_setup, + .open = ipmi_lanplus_open, + .close = ipmi_lanplus_close, + .sendrecv = ipmi_lanplus_send_ipmi_cmd, + .recv_sol = ipmi_lanplus_recv_sol, + .send_sol = ipmi_lanplus_send_sol, + .keepalive = ipmi_lanplus_keepalive, + .set_max_request_data_size = ipmi_lanp_set_max_rq_data_size, + .set_max_response_data_size = ipmi_lanp_set_max_rp_data_size, + .target_addr = IPMI_BMC_SLAVE_ADDR, + }; +*/ +}; +#endif /* NEWLIB_LANPLUS_H_ */ diff --git a/Online/IPMI/src/NewLib/NodeConfiguration.h b/Online/IPMI/src/NewLib/NodeConfiguration.h new file mode 100644 index 0000000000000000000000000000000000000000..14797a48d7564e224d8e3f42e583d7e36d040b89 --- /dev/null +++ b/Online/IPMI/src/NewLib/NodeConfiguration.h @@ -0,0 +1,59 @@ +//========================================================================== +// LHCb Online software suite +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see OnlineSys/LICENSE. +// +// Author : B.Jost +// +//========================================================================== +/* + * NodeThread.h + * + * Created on: Feb 11, 2016 + * Author: beat + */ + +#ifndef SOURCE_DIRECTORY__ONLINE_IPMI_SRC_NEWLIB_NODECONFIGURATION_H_ +#define SOURCE_DIRECTORY__ONLINE_IPMI_SRC_NEWLIB_NODECONFIGURATION_H_ + +#include <string> +#include <mutex> +using namespace std; +class NodeConfiguration +{ + public: + NodeConfiguration(string &N, string &U, string &P, string *sp,string IF = "",int statepoll=1, int setuppoll=10) + { + NodeName = N; + UserName = U; + Password = P; + ServicePrefix = sp; + Interface = IF; + statePollDelay = statepoll; + setupRetryDelay = setuppoll; + } + NodeConfiguration() + { + NodeName = ""; + UserName = ""; + Password = ""; + optRest = ""; + ServicePrefix = 0; + Interface = ""; + this->statePollDelay = 1; + this->setupRetryDelay =10; + } + string NodeName; + string UserName; + string Password; + string *ServicePrefix; + string optRest; + string Interface; + int statePollDelay; + int setupRetryDelay; + int cipher=0; +}; +#endif /* SOURCE_DIRECTORY__ONLINE_IPMI_SRC_NEWLIB_NODECONFIGURATION_H_ */ diff --git a/Online/IPMI/src/NewLib/NodeThread.cpp b/Online/IPMI/src/NewLib/NodeThread.cpp index f20b51a1690d542442f400e2bde5972963919086..65b11a72cdc2c732ab0a934722c5881c29ae90f7 100644 --- a/Online/IPMI/src/NewLib/NodeThread.cpp +++ b/Online/IPMI/src/NewLib/NodeThread.cpp @@ -27,13 +27,16 @@ #include "dim/dis.hxx" #include "log.h" -#include "src/NewLib/IPMINode.h" -#include "src/NewLib/ipmi_intf.h" +#include "IPMINode.h" +#include "ipmi_intf.h" #include "NodeThread.h" +#include "ipmi_constants.h" +#include "lan.h" +#include "LANPlus.h" using namespace std; -void NodeThread(NodeConfiguration *config,string *setup_fail, mutex *setup_fail_mtx ) +template <class T> void NodeThread(NodeConfiguration *config,string *setup_fail, mutex *setup_fail_mtx ) { int status; string uname; @@ -42,12 +45,13 @@ void NodeThread(NodeConfiguration *config,string *setup_fail, mutex *setup_fail_ pword = config->Password; string nam = config->NodeName; string *ServicePrefix = config->ServicePrefix; - IPMINode *nod; + IPMINode<T> *nod; while (1) { // m.lock(); - nod = new IPMINode(nam, uname, pword); - status = nod->setup((char*)ServicePrefix->c_str()); + + nod = new IPMINode<T>(nam, uname, pword); + status = nod->setup((char*)ServicePrefix->c_str(),*config); if (status == 0) { // m.unlock(); @@ -102,8 +106,8 @@ void NodeThread(NodeConfiguration *config,string *setup_fail, mutex *setup_fail_ sleep(2); while (1) { - nod = new IPMINode(nam, uname, pword); - status = nod->setup((char*)ServicePrefix->c_str()); + nod = new IPMINode<T>(nam, uname, pword); + status = nod->setup((char*)ServicePrefix->c_str(),*config); if (status == 0) { // Printf("Setup of node %s successful\n", nam.c_str()); @@ -189,5 +193,6 @@ void NodeThread(NodeConfiguration *config,string *setup_fail, mutex *setup_fail_ sleep(config->statePollDelay); } } - +template void NodeThread<lan>(NodeConfiguration *config,string *setup_fail, mutex *setup_fail_mtx ); +template void NodeThread<LANPlus>(NodeConfiguration *config,string *setup_fail, mutex *setup_fail_mtx ); diff --git a/Online/IPMI/src/NewLib/NodeThread.h b/Online/IPMI/src/NewLib/NodeThread.h index 30822d309188e6c8d0bede85c8e9bb8c543fe135..8478eb6db7eb19c7a95a410f59e6dd9ca6b5d06d 100644 --- a/Online/IPMI/src/NewLib/NodeThread.h +++ b/Online/IPMI/src/NewLib/NodeThread.h @@ -21,36 +21,8 @@ #include <string> #include <mutex> +#include "NodeConfiguration.h" using namespace std; -class NodeConfiguration -{ - public: - NodeConfiguration(string &N, string &U, string &P, string *sp, - int statepoll=1, int setuppoll=10) - { - NodeName = N; - UserName = U; - Password = P; - ServicePrefix = sp; - this->statePollDelay = statepoll; - this->setupRetryDelay = setuppoll; - } - NodeConfiguration() - { - NodeName = ""; - UserName = ""; - Password = ""; - ServicePrefix = 0; - this->statePollDelay = 1; - this->setupRetryDelay =10; - } - string NodeName; - string UserName; - string Password; - string *ServicePrefix; - int statePollDelay; - int setupRetryDelay; -}; -void NodeThread(NodeConfiguration *config, string *setup_fail, +template <class T> void NodeThread(NodeConfiguration *config, string *setup_fail, mutex *setup_fail_mtx); #endif /* SOURCE_DIRECTORY__ONLINE_IPMI_SRC_NEWLIB_NODETHREAD_H_ */ diff --git a/Online/IPMI/src/NewLib/asf.h b/Online/IPMI/src/NewLib/asf.h index 177a0921f367b6cdaedbae8dbf0ccd18e6ca0cac..431e9a2e6178f4648ffd0ed3044343f05f1973e5 100644 --- a/Online/IPMI/src/NewLib/asf.h +++ b/Online/IPMI/src/NewLib/asf.h @@ -45,7 +45,7 @@ #define IPMI_ASF_H #include "helper.h" -#include "lan.h" +//#include "lan.h" #define ASF_RMCP_IANA 0x000011be @@ -81,6 +81,6 @@ struct asf_hdr { #pragma pack(0) #endif -int handle_asf(struct ipmi_intf * intf, uint8_t * data, int data_len); +template <class T>int handle_asf( ipmi_intf<T> * intf, uint8_t * data, int data_len); #endif /* IPMI_ASF_H */ diff --git a/Online/IPMI/src/NewLib/auth.cpp b/Online/IPMI/src/NewLib/auth.cpp index 55e6dc75b1055eb83d052d27b6d97966eca1f248..f6fcd1254b30e67c4ec55ea709623f37b3796470 100644 --- a/Online/IPMI/src/NewLib/auth.cpp +++ b/Online/IPMI/src/NewLib/auth.cpp @@ -68,13 +68,15 @@ #else # include <md5.h> #endif +#include "lan.h" +#include "LANPlus.h" /* * multi-session authcode generation for MD5 * H(password + session_id + msg + session_seq + password) * * Use OpenSSL implementation of MD5 algorithm if found */ -uint8_t * ipmi_auth::ipmi_auth_md5(ipmi_session * s, uint8_t * data, int data_len) +template<class T> uint8_t * ipmi_auth<T>::ipmi_auth_md5(ipmi_session<T> * s, uint8_t * data, int data_len) { #ifdef HAVE_CRYPTO_MD5 MD5_CTX ctx; @@ -164,7 +166,7 @@ uint8_t * ipmi_auth::ipmi_auth_md2( ipmi_session * s, uint8_t * data, int data_l return md; } #else /*HAVE_CRYPTO_MD2*/ -uint8_t * ipmi_auth::ipmi_auth_md2( ipmi_session* /* s */, uint8_t* /* data */, int /* data_len */) +template <class T> uint8_t * ipmi_auth<T>::ipmi_auth_md2( ipmi_session<T>* /* s */, uint8_t* /* data */, int /* data_len */) { memset(md, 0, 16); Printf("WARNING: No internal support for MD2! " @@ -174,7 +176,7 @@ uint8_t * ipmi_auth::ipmi_auth_md2( ipmi_session* /* s */, uint8_t* /* data */, #endif /*HAVE_CRYPTO_MD2*/ /* special authentication method */ -uint8_t * ipmi_auth::ipmi_auth_special( ipmi_session * s) +template <class T> uint8_t * ipmi_auth<T>::ipmi_auth_special( ipmi_session<T> * s) { #ifdef HAVE_CRYPTO_MD5 MD5_CTX ctx; @@ -226,4 +228,5 @@ uint8_t * ipmi_auth::ipmi_auth_special( ipmi_session * s) return digest; #endif /*HAVE_CRYPTO_MD5*/ } - +template class ipmi_auth<lan>; +template class ipmi_auth<LANPlus>; diff --git a/Online/IPMI/src/NewLib/auth.h b/Online/IPMI/src/NewLib/auth.h index e73c4647f8d29a9a4264f74bc75f2d0b5350a6fc..b159620de170bdf755b45d413cb9383ff21db231 100644 --- a/Online/IPMI/src/NewLib/auth.h +++ b/Online/IPMI/src/NewLib/auth.h @@ -42,18 +42,19 @@ */ #ifndef IPMI_AUTH_H #define IPMI_AUTH_H -class ipmi_session; +//class ipmi_session; #ifndef md5_byte_t typedef unsigned char md5_byte_t; #endif - -class ipmi_auth +template <typename T> class ipmi_session; +template <typename T>class ipmi_auth { public: uint8_t md[16]; md5_byte_t digest[16]; - uint8_t * ipmi_auth_md2( ipmi_session * s, uint8_t * data, int data_len); - uint8_t * ipmi_auth_md5( ipmi_session * s, uint8_t * data, int data_len); - uint8_t * ipmi_auth_special( ipmi_session * s); + ipmi_auth(){}; + uint8_t * ipmi_auth_md2( ipmi_session<T> * s, uint8_t * data, int data_len); + uint8_t * ipmi_auth_md5( ipmi_session<T> * s, uint8_t * data, int data_len); + uint8_t * ipmi_auth_special( ipmi_session<T> * s); }; #endif /*IPMI_AUTH_H*/ diff --git a/Online/IPMI/src/NewLib/helper.cpp b/Online/IPMI/src/NewLib/helper.cpp index 6f74f2d7dd1ca969bddf25f312fa7eaf555c49f2..e423d63d136cb5bc024f329368f7f0ddeab01c46 100644 --- a/Online/IPMI/src/NewLib/helper.cpp +++ b/Online/IPMI/src/NewLib/helper.cpp @@ -56,7 +56,8 @@ #include <fcntl.h> #include <errno.h> #include <assert.h> - +#include "lan.h" +#include "LANPlus.h" #if HAVE_CONFIG_H # include "config.h" #endif @@ -80,17 +81,17 @@ #include "ipmi_mc.h" extern int verbose; -uint32_t ipmi_helper::buf2long(uint8_t * buf) +template <class T> uint32_t ipmi_helper<T>::buf2long(uint8_t * buf) { return (uint32_t)(buf[3] << 24 | buf[2] << 16 | buf[1] << 8 | buf[0]); } -uint16_t ipmi_helper::buf2short(uint8_t * buf) +template <class T> uint16_t ipmi_helper<T>::buf2short(uint8_t * buf) { return (uint16_t)(buf[1] << 8 | buf[0]); } -const char * ipmi_helper::buf2str(uint8_t * buf, int len) +template <class T> const char * ipmi_helper<T>::buf2str(uint8_t * buf, int len) { int i; @@ -108,7 +109,7 @@ const char * ipmi_helper::buf2str(uint8_t * buf, int len) return (const char *)str; } -void ipmi_helper::printbuf(const uint8_t * buf, int len, const char * desc) +template <class T> void ipmi_helper<T>::printbuf(const uint8_t * buf, int len, const char * desc) { int i; if (len <= 0) @@ -126,7 +127,7 @@ void ipmi_helper::printbuf(const uint8_t * buf, int len, const char * desc) fPrintf(stderr, "\n"); } -const char * ipmi_helper::val2str(uint16_t val, const valstr *vs) +template <class T> const char * ipmi_helper<T>::val2str(uint16_t val, const valstr *vs) { int i; @@ -142,7 +143,7 @@ const char * ipmi_helper::val2str(uint16_t val, const valstr *vs) return un_str; } -const char * ipmi_helper::oemval2str(uint32_t oem, uint16_t val, +template <class T> const char * ipmi_helper<T>::oemval2str(uint32_t oem, uint16_t val, const oemvalstr *vs) { @@ -170,7 +171,7 @@ const char * ipmi_helper::oemval2str(uint32_t oem, uint16_t val, * returns zero on success * returns (-1) if one of args is NULL, (-2) invalid input, (-3) for *flow */ -int ipmi_helper::str2double(const char * str, double * double_ptr) +template <class T> int ipmi_helper<T>::str2double(const char * str, double * double_ptr) { char * end_ptr = 0; if (!str || !double_ptr) @@ -197,7 +198,7 @@ int ipmi_helper::str2double(const char * str, double * double_ptr) * returns zero on success * returns (-1) if one of args is NULL, (-2) invalid input, (-3) for *flow */ -int ipmi_helper::str2long(const char * str, int64_t * lng_ptr) +template <class T> int ipmi_helper<T>::str2long(const char * str, int64_t * lng_ptr) { char * end_ptr = 0; if (!str || !lng_ptr) @@ -224,7 +225,7 @@ int ipmi_helper::str2long(const char * str, int64_t * lng_ptr) * returns zero on success * returns (-1) if one of args is NULL, (-2) invalid input, (-3) for *flow */ -int ipmi_helper::str2ulong(const char * str, uint64_t * ulng_ptr) +template <class T> int ipmi_helper<T>::str2ulong(const char * str, uint64_t * ulng_ptr) { char * end_ptr = 0; if (!str || !ulng_ptr) @@ -251,7 +252,7 @@ int ipmi_helper::str2ulong(const char * str, uint64_t * ulng_ptr) * returns zero on success * returns (-1) if one of args is NULL, (-2) invalid input, (-3) for *flow */ -int ipmi_helper::str2int(const char * str, int32_t * int_ptr) +template <class T> int ipmi_helper<T>::str2int(const char * str, int32_t * int_ptr) { int rc = 0; int64_t arg_long = 0; @@ -278,7 +279,7 @@ int ipmi_helper::str2int(const char * str, int32_t * int_ptr) * returns zero on success * returns (-1) if one of args is NULL, (-2) invalid input, (-3) for *flow */ -int ipmi_helper::str2uint(const char * str, uint32_t * uint_ptr) +template <class T> int ipmi_helper<T>::str2uint(const char * str, uint32_t * uint_ptr) { int rc = 0; uint64_t arg_ulong = 0; @@ -305,7 +306,7 @@ int ipmi_helper::str2uint(const char * str, uint32_t * uint_ptr) * returns zero on success * returns (-1) if one of args is NULL, (-2) invalid input, (-3) for *flow */ -int ipmi_helper::str2short(const char * str, int16_t * shrt_ptr) +template <class T> int ipmi_helper<T>::str2short(const char * str, int16_t * shrt_ptr) { int rc = (-3); int64_t arg_long = 0; @@ -332,7 +333,7 @@ int ipmi_helper::str2short(const char * str, int16_t * shrt_ptr) * returns zero on success * returns (-1) if one of args is NULL, (-2) invalid input, (-3) for *flow */ -int ipmi_helper::str2ushort(const char * str, uint16_t * ushrt_ptr) +template <class T> int ipmi_helper<T>::str2ushort(const char * str, uint16_t * ushrt_ptr) { int rc = (-3); uint64_t arg_ulong = 0; @@ -359,7 +360,7 @@ int ipmi_helper::str2ushort(const char * str, uint16_t * ushrt_ptr) * returns zero on success * returns (-1) if one of args is NULL, (-2) or (-3) if conversion fails */ -int ipmi_helper::str2char(const char *str, int8_t * chr_ptr) +template <class T> int ipmi_helper<T>::str2char(const char *str, int8_t * chr_ptr) { int rc = (-3); int64_t arg_long = 0; @@ -385,7 +386,7 @@ int ipmi_helper::str2char(const char *str, int8_t * chr_ptr) * returns zero on success * returns (-1) if one of args is NULL, (-2) or (-3) if conversion fails */ -int ipmi_helper::str2uchar(const char * str, uint8_t * uchr_ptr) +template <class T> int ipmi_helper<T>::str2uchar(const char * str, uint8_t * uchr_ptr) { int rc = (-3); uint64_t arg_ulong = 0; @@ -404,7 +405,7 @@ int ipmi_helper::str2uchar(const char * str, uint8_t * uchr_ptr) return 0; } /* str2uchar(...) */ -uint16_t ipmi_helper::str2val(const char *str, const valstr *vs) +template <class T> uint16_t ipmi_helper<T>::str2val(const char *str, const valstr *vs) { int i; @@ -422,8 +423,7 @@ uint16_t ipmi_helper::str2val(const char *str, const valstr *vs) * @title: name of this value string list * @loglevel: what log level to print, -1 for stdout */ -void -ipmi_helper::print_valstr(const valstr * vs, const char * title, int loglevel) +template <class T> void ipmi_helper<T>::print_valstr(const valstr * vs, const char * title, int loglevel) { int i; @@ -471,8 +471,7 @@ ipmi_helper::print_valstr(const valstr * vs, const char * title, int loglevel) * @title: name of this value string list * @loglevel: what log level to print, -1 for stdout */ -void -ipmi_helper::print_valstr_2col(const valstr * vs, const char * title, int loglevel) +template <class T> void ipmi_helper<T>::print_valstr_2col(const valstr * vs, const char * title, int loglevel) { int i; @@ -518,8 +517,7 @@ ipmi_helper::print_valstr_2col(const valstr * vs, const char * title, int logle * @d: buffer to check * @s: position in buffer to start checksum from */ -uint8_t -ipmi_helper::ipmi_csum(uint8_t * d, int s) +template <class T> uint8_t ipmi_helper<T>::ipmi_csum(uint8_t * d, int s) { uint8_t c = 0; for (; s > 0; s--, d++) @@ -535,8 +533,7 @@ ipmi_helper::ipmi_csum(uint8_t * d, int s) * returns pointer to file handler on success * returns NULL on error */ -FILE * -ipmi_helper::ipmi_open_file(const char * file, int rw) +template <class T> FILE *ipmi_helper<T>::ipmi_open_file(const char * file, int rw) { struct stat st1, st2; FILE * fp; @@ -625,8 +622,7 @@ ipmi_helper::ipmi_open_file(const char * file, int rw) return fp; } -void -ipmi_helper::ipmi_start_daemon( ipmi_intf *intf) +template <class T> void ipmi_helper<T>::ipmi_start_daemon( ipmi_intf<T> *intf) { pid_t pid; int fd; @@ -697,8 +693,8 @@ ipmi_helper::ipmi_start_daemon( ipmi_intf *intf) * returns zero on success * returns (-1) on error and message is printed on STDERR */ -int -ipmi_helper::is_fru_id(const char *argv_ptr, uint8_t *fru_id_ptr) +template <class T> int +ipmi_helper<T>::is_fru_id(const char *argv_ptr, uint8_t *fru_id_ptr) { if (!argv_ptr || !fru_id_ptr) { lPrintf(LOG_ERR, "is_fru_id(): invalid argument(s)."); @@ -726,8 +722,8 @@ ipmi_helper::is_fru_id(const char *argv_ptr, uint8_t *fru_id_ptr) * returns zero on success * returns (-1) on error and message is printed on STDERR */ -int -ipmi_helper::is_ipmi_channel_num(const char *argv_ptr, uint8_t *channel_ptr) +template <class T> int +ipmi_helper<T>::is_ipmi_channel_num(const char *argv_ptr, uint8_t *channel_ptr) { if (!argv_ptr || !channel_ptr) { lPrintf(LOG_ERR, @@ -756,8 +752,8 @@ ipmi_helper::is_ipmi_channel_num(const char *argv_ptr, uint8_t *channel_ptr) * returns zero on success * returns (-1) on error and message is printed on STDERR */ -int -ipmi_helper::is_ipmi_user_id(const char *argv_ptr, uint8_t *ipmi_uid_ptr) +template <class T> int +ipmi_helper<T>::is_ipmi_user_id(const char *argv_ptr, uint8_t *ipmi_uid_ptr) { if (!argv_ptr || !ipmi_uid_ptr) { lPrintf(LOG_ERR, @@ -776,16 +772,65 @@ ipmi_helper::is_ipmi_user_id(const char *argv_ptr, uint8_t *ipmi_uid_ptr) IPMI_UID_MIN, IPMI_UID_MAX); return (-1); } +template <class T> int +ipmi_helper<T>::is_ipmi_user_priv_limit(const char *argv_ptr, uint8_t *ipmi_priv_limit_ptr) +{ + if (!argv_ptr || !ipmi_priv_limit_ptr) { + lPrintf(LOG_ERR, + "is_ipmi_user_priv_limit(): invalid argument(s)."); + return (-1); + } + if ((str2uchar(argv_ptr, ipmi_priv_limit_ptr) != 0) + || ((*ipmi_priv_limit_ptr < 0x01 + || *ipmi_priv_limit_ptr > 0x05) + && *ipmi_priv_limit_ptr != 0x0F)) { + lPrintf(LOG_ERR, + "Given Privilege Limit '%s' is invalid.", + argv_ptr); + lPrintf(LOG_ERR, + "Privilege Limit is limited to <0x1..0x5> and <0xF>."); + return (-1); + } + return 0; +} + +template <class T> int ipmi_helper<T>::eval_ccode(const int ccode) +{ + if (ccode == 0) { + return 0; + } else if (ccode < 0) { + switch (ccode) { + case (-1): + lPrintf(LOG_ERR, "IPMI response is NULL."); + break; + case (-2): + lPrintf(LOG_ERR, "Unexpected data length received."); + break; + case (-3): + lPrintf(LOG_ERR, "Invalid function parameter."); + break; + case (-4): + lPrintf(LOG_ERR, "ipmitool: malloc failure."); + break; + default: + break; + } + return (-1); + } else { + lPrintf(LOG_ERR, "IPMI command failed: %s", + val2str(ccode, completion_code_vals)); + return (-1); + } +} -uint16_t -ipmi_helper::ipmi_get_oem_id( ipmi_intf *intf) +template <class T> uint16_t ipmi_helper<T>::ipmi_get_oem_id( ipmi_intf<T> *intf) { /* Execute a Get Board ID command to determine the board */ struct ipmi_rs *rsp; struct ipmi_rq req; uint16_t oem_id; - - memset(&req, 0, sizeof(req)); + req.zero(); +// memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_TSOL; req.msg.cmd = 0x21; req.msg.data_len = 0; @@ -806,8 +851,7 @@ ipmi_helper::ipmi_get_oem_id( ipmi_intf *intf) return oem_id; } #define BMC_GET_DEVICE_ID 0x01 -IPMI_OEM -ipmi_helper::ipmi_get_oem(ipmi_intf * intf) +template <class T> IPMI_OEM ipmi_helper<T>::ipmi_get_oem(ipmi_intf<T> * intf) { /* Execute a Get Device ID command to determine the OEM */ struct ipmi_rs * rsp; @@ -829,8 +873,8 @@ ipmi_helper::ipmi_get_oem(ipmi_intf * intf) if (intf->opened && intf->manufacturer_id != IPMI_OEM_UNKNOWN) { return intf->manufacturer_id; } - - memset(&req, 0, sizeof(req)); + req.zero(); +// memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_APP; req.msg.cmd = BMC_GET_DEVICE_ID; req.msg.data_len = 0; @@ -853,3 +897,6 @@ ipmi_helper::ipmi_get_oem(ipmi_intf * intf) return (IPMI_OEM)IPM_DEV_MANUFACTURER_ID(devid->manufacturer_id); } + +template class ipmi_helper<lan>; +template class ipmi_helper<LANPlus>; diff --git a/Online/IPMI/src/NewLib/helper.h b/Online/IPMI/src/NewLib/helper.h index 44905c3ad9b1d19bde821cf7109b77efcb539cbf..0157a69614d2fc4c6c853d80395d13a2fa0f4c5f 100644 --- a/Online/IPMI/src/NewLib/helper.h +++ b/Online/IPMI/src/NewLib/helper.h @@ -70,7 +70,7 @@ # define IPMI_UID_MAX 63 #endif -class ipmi_intf; +//template <class ipmi_intf> ;//class ipmi_intf; #define IPM_DEV_MANUFACTURER_ID(x) \ ((uint32_t) ((x[2] & 0x0F) << 16 | x[1] << 8 | x[0])) #ifdef HAVE_PRAGMA_PACK @@ -102,6 +102,7 @@ class valstr val = v; str = s; } + ~valstr(){}; ; }; class oemvalstr @@ -111,7 +112,8 @@ class oemvalstr uint16_t val; const char * str; }; -class ipmi_helper +template <class G> class ipmi_intf; +template <class T> class ipmi_helper { public: char str[2049]; @@ -136,6 +138,7 @@ class ipmi_helper uint16_t str2val(const char * str, const valstr * vs); void print_valstr(const valstr * vs, const char * title, int loglevel); void print_valstr_2col(const valstr * vs, const char * title, int loglevel); + int is_ipmi_user_priv_limit(const char *argv_ptr, uint8_t *ipmi_priv_limit_ptr); uint16_t buf2short(uint8_t * buf); uint32_t buf2long(uint8_t * buf); @@ -143,9 +146,11 @@ class ipmi_helper void printbuf(const uint8_t * buf, int len, const char * desc); uint8_t ipmi_csum(uint8_t * d, int s); FILE * ipmi_open_file(const char * file, int rw); - void ipmi_start_daemon(ipmi_intf *intf); - uint16_t ipmi_get_oem_id(ipmi_intf *intf); - IPMI_OEM ipmi_get_oem(ipmi_intf *intf); + int eval_ccode(const int ccode); + + void ipmi_start_daemon(ipmi_intf<T> *intf); + uint16_t ipmi_get_oem_id(ipmi_intf<T> *intf); + IPMI_OEM ipmi_get_oem(ipmi_intf<T> *intf); }; #define ipmi_open_file_read(file) ipmi_open_file(file, 0) #define ipmi_open_file_write(file) ipmi_open_file(file, 1) diff --git a/Online/IPMI/src/NewLib/hpm2.cpp b/Online/IPMI/src/NewLib/hpm2.cpp deleted file mode 100644 index c5205611854e1bd5c537b4fc56534f0af8ef3439..0000000000000000000000000000000000000000 --- a/Online/IPMI/src/NewLib/hpm2.cpp +++ /dev/null @@ -1,305 +0,0 @@ -//========================================================================== -// LHCb Online software suite -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see OnlineSys/LICENSE. -// -// Author : B.Jost -// -//========================================================================== -/* - * Copyright (c) 2012 Pigeon Point Systems. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Pigeon Point Systems nor the names of - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. - * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. - * PIGEON POINT SYSTEMS ("PPS") AND ITS LICENSORS SHALL NOT BE LIABLE - * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING - * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL - * PPS OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, - * OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR - * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF - * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, - * EVEN IF PPS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - */ - -//#include <ipmitool/bswap.h> -//#include <ipmitool/hpm2.h> -//#include <ipmitool/ipmi_intf.h> -//#include <ipmitool/log.h> -//#include <ipmitool/bswap.h> -#include "log.h" -#include "bswap.h" -#include "hpm2.h" -#include "ipmi_intf.h" -#include "bswap.h" - -#if HAVE_PRAGMA_PACK -# pragma pack(push, 1) -#endif - -/* HPM.x Get Capabilities request */ -struct hpmx_cmd_get_capabilities_rq { - uint8_t picmg_id; - uint8_t hpmx_id; -} ATTRIBUTE_PACKING; - -/* HPM.2 Get Capabilities response */ -struct hpm2_cmd_get_capabilities_rp { - uint8_t picmg_id; - struct hpm2_lan_attach_capabilities caps; -} ATTRIBUTE_PACKING; - -#if HAVE_PRAGMA_PACK -# pragma pack(pop) -#endif - -/* IPMI Get LAN Configuration Parameters command */ -#define IPMI_LAN_GET_CONFIG 0x02 - -int hpm2_get_capabilities(ipmi_intf * intf, - struct hpm2_lan_attach_capabilities * caps) -{ - struct ipmi_rq req; - struct ipmi_rs * rsp; - struct hpmx_cmd_get_capabilities_rq rq; - - /* reset result */ - memset(caps, 0, sizeof(struct hpm2_lan_attach_capabilities)); - - /* prepare request */ - rq.picmg_id = 0; - rq.hpmx_id = 2; - - /* prepare request */ - memset(&req, 0, sizeof(req)); - req.msg.netfn = IPMI_NETFN_PICMG; - req.msg.cmd = HPM2_GET_LAN_ATTACH_CAPABILITIES; - req.msg.data = (uint8_t *)&rq; - req.msg.data_len = sizeof(rq); - - - /* send */ - rsp = intf->sendrecv( &req); - - if (!rsp) { - lPrintf(LOG_NOTICE, "Error sending request."); - return -1; - } - - if (rsp->ccode == 0xC1) { - lPrintf(LOG_DEBUG, "IPM Controller is not HPM.2 compatible"); - return rsp->ccode; - } else if (rsp->ccode) { - lPrintf(LOG_NOTICE, "Get HPM.x Capabilities request failed," - " compcode = %x", rsp->ccode); - return rsp->ccode; - } - - /* check response length */ - if (rsp->data_len < 2 || rsp->data_len > 10) { - lPrintf(LOG_NOTICE, "Bad response length, len=%d", rsp->data_len); - return -1; - } - - /* check HPM.x identifier */ - if (rsp->data[1] != 2) { - lPrintf(LOG_NOTICE, "Bad HPM.x ID, id=%d", rsp->data[1]); - return rsp->ccode; - } - - /* - * this hardly can happen, since completion code is already checked. - * but check for safety - */ - if (rsp->data_len < 4) { - lPrintf(LOG_NOTICE, "Bad response length, len=%d", rsp->data_len); - return -1; - } - - /* copy HPM.2 capabilities */ - memcpy(caps, rsp->data + 2, rsp->data_len - 2); - -#if WORDS_BIGENDIAN - /* swap bytes to convert from little-endian format */ - caps->lan_channel_mask = BSWAP_16(caps->lan_channel_mask); -#endif - - /* check HPM.2 revision */ - if (caps->hpm2_revision_id != HPM2_REVISION) { - lPrintf(LOG_NOTICE, "Bad HPM.2 revision, rev=%d", - caps->hpm2_revision_id); - return -1; - } - - if (!caps->lan_channel_mask) { - return -1; - } - - /* check response length */ - if (rsp->data_len < 8) { - lPrintf(LOG_NOTICE, "Bad response length, len=%d", rsp->data_len); - return -1; - } - - /* check HPM.2 LAN parameters start */ - if (caps->hpm2_lan_params_start < 0xC0) { - lPrintf(LOG_NOTICE, "Bad HPM.2 LAN params start, start=%x", - caps->hpm2_lan_params_start); - return -1; - } - - /* check HPM.2 LAN parameters revision */ - if (caps->hpm2_lan_params_rev != HPM2_LAN_PARAMS_REV) { - lPrintf(LOG_NOTICE, "Bad HPM.2 LAN params revision, rev=%d", - caps->hpm2_lan_params_rev); - return -1; - } - - /* check for HPM.2 SOL extension */ - if (!(caps->hpm2_caps & HPM2_CAPS_SOL_EXTENSION)) { - /* no further checks */ - return 0; - } - - /* check response length */ - if (rsp->data_len < 10) { - lPrintf(LOG_NOTICE, "Bad response length, len=%d", rsp->data_len); - return -1; - } - - /* check HPM.2 SOL parameters start */ - if (caps->hpm2_sol_params_start < 0xC0) { - lPrintf(LOG_NOTICE, "Bad HPM.2 SOL params start, start=%x", - caps->hpm2_sol_params_start); - return -1; - } - - /* check HPM.2 SOL parameters revision */ - if (caps->hpm2_sol_params_rev != HPM2_SOL_PARAMS_REV) { - lPrintf(LOG_NOTICE, "Bad HPM.2 SOL params revision, rev=%d", - caps->hpm2_sol_params_rev); - return -1; - } - - return 0; -} - -int hpm2_get_lan_channel_capabilities(ipmi_intf * intf, - uint8_t hpm2_lan_params_start, - struct hpm2_lan_channel_capabilities * caps) -{ - struct ipmi_rq req; - struct ipmi_rs * rsp; - uint8_t rq[4]; - - /* reset result */ - memset(caps, 0, sizeof(struct hpm2_lan_channel_capabilities)); - - /* prepare request */ - memset(&req, 0, sizeof(req)); - req.msg.netfn = IPMI_NETFN_TRANSPORT; - req.msg.cmd = IPMI_LAN_GET_CONFIG; - req.msg.data = (uint8_t *)&rq; - req.msg.data_len = sizeof(rq); - - /* prepare request data */ - rq[0] = 0xE; /* sending channel */ - rq[1] = hpm2_lan_params_start; /* HPM.2 Channel Caps */ - rq[2] = rq[3] = 0; - - /* send */ - rsp = intf->sendrecv( &req); - - if (rsp) { - lPrintf(LOG_NOTICE, "Error sending request"); - return -1; - } - - if (rsp->ccode == 0x80) { - lPrintf(LOG_DEBUG, "HPM.2 Channel Caps parameter is not supported"); - return rsp->ccode; - } else if (rsp->ccode) { - lPrintf(LOG_NOTICE, "Get LAN Configuration Parameters request failed," - " compcode = %x", rsp->ccode); - return rsp->ccode; - } - - /* check response length */ - if (rsp->data_len != sizeof (struct hpm2_lan_channel_capabilities) + 1) { - lPrintf(LOG_NOTICE, "Bad response length, len=%d", rsp->data_len); - return -1; - } - - /* check parameter revision */ - if (rsp->data[0] != - LAN_PARAM_REV(HPM2_LAN_PARAMS_REV, HPM2_LAN_PARAMS_REV)) { - lPrintf(LOG_NOTICE, "Bad HPM.2 LAN parameter revision, rev=%d", - rsp->data[0]); - return -1; - } - - /* copy parameter data */ - memcpy(caps, &rsp->data[1], sizeof (struct hpm2_lan_channel_capabilities)); - -#if WORDS_BIGENDIAN - /* swap bytes to convert from little-endian format */ - caps->max_inbound_pld_size = BSWAP_16(caps->max_inbound_pld_size); - caps->max_outbound_pld_size = BSWAP_16(caps->max_outbound_pld_size); -#endif - - return 0; -} - -int hpm2_detect_max_payload_size( ipmi_intf * intf) -{ - struct hpm2_lan_attach_capabilities attach_caps; - struct hpm2_lan_channel_capabilities channel_caps; - int err; - - /* query HPM.2 support */ - err = hpm2_get_capabilities(intf, &attach_caps); - - /* check if HPM.2 is supported */ - if (err != 0 || !attach_caps.lan_channel_mask) { - return err; - } - - /* query channel capabilities */ - err = hpm2_get_lan_channel_capabilities(intf, - attach_caps.hpm2_lan_params_start, &channel_caps); - - /* check if succeeded */ - if (err != 0) { - return err; - } - - /* update request and response sizes */ - intf->ipmi_intf_set_max_request_data_size(channel_caps.max_inbound_pld_size - 7); - intf->ipmi_intf_set_max_response_data_size(channel_caps.max_outbound_pld_size - 8); - - /* print debug info */ - lPrintf(LOG_DEBUG, "Set maximum request size to %d\n" - "Set maximum response size to %d", - intf->max_request_data_size, intf->max_response_data_size); - - return 0; -} diff --git a/Online/IPMI/src/NewLib/hpm2.h b/Online/IPMI/src/NewLib/hpm2.h index 58af487a93dda57c51f2dc575f67e62a92dfdb93..36dbb15a2e238f1c148ef9186d6809f4563d8797 100644 --- a/Online/IPMI/src/NewLib/hpm2.h +++ b/Online/IPMI/src/NewLib/hpm2.h @@ -55,6 +55,7 @@ * LSN = oldest revision parameter is * backward compatible with. */ #define LAN_PARAM_REV(x, y) (((x) << 4) | ((y) & 0xF)) +#define IPMI_LAN_GET_CONFIG 0x02 /* HPM.2 capabilities */ #define HPM2_CAPS_SOL_EXTENSION 0x01 @@ -87,6 +88,25 @@ struct hpm2_lan_channel_capabilities { uint16_t max_outbound_pld_size; } /*ATTRIBUTE_PACKING*/; +#if HAVE_PRAGMA_PACK +# pragma pack(pop) +#endif +#if HAVE_PRAGMA_PACK +# pragma pack(push, 1) +#endif + +/* HPM.x Get Capabilities request */ +struct hpmx_cmd_get_capabilities_rq { + uint8_t picmg_id; + uint8_t hpmx_id; +} ATTRIBUTE_PACKING; + +/* HPM.2 Get Capabilities response */ +struct hpm2_cmd_get_capabilities_rp { + uint8_t picmg_id; + struct hpm2_lan_attach_capabilities caps; +} ATTRIBUTE_PACKING; + #if HAVE_PRAGMA_PACK # pragma pack(pop) #endif @@ -94,9 +114,231 @@ struct hpm2_lan_channel_capabilities { /* HPM.2 command assignments */ #define HPM2_GET_LAN_ATTACH_CAPABILITIES 0x3E -extern int hpm2_get_capabilities(struct ipmi_intf * intf, - struct hpm2_lan_attach_capabilities * caps); -extern int hpm2_get_lan_channel_capabilities(struct ipmi_intf * intf, +template <class T> int hpm2_get_capabilities(ipmi_intf<T> * intf, + struct hpm2_lan_attach_capabilities * caps) +{ + struct ipmi_rq req; + struct ipmi_rs * rsp; + struct hpmx_cmd_get_capabilities_rq rq; + + /* reset result */ + memset((void*)caps, 0, sizeof(struct hpm2_lan_attach_capabilities)); + + /* prepare request */ + rq.picmg_id = 0; + rq.hpmx_id = 2; + + /* prepare request */ + req.zero(); +// memset(&req, 0, sizeof(req)); + req.msg.netfn = IPMI_NETFN_PICMG; + req.msg.cmd = HPM2_GET_LAN_ATTACH_CAPABILITIES; + req.msg.data = (uint8_t *)&rq; + req.msg.data_len = sizeof(rq); + + + /* send */ + rsp = intf->sendrecv( &req); + + if (!rsp) { + lPrintf(LOG_NOTICE, "Error sending request."); + return -1; + } + + if (rsp->ccode == 0xC1) { + lPrintf(LOG_DEBUG, "IPM Controller is not HPM.2 compatible"); + return rsp->ccode; + } else if (rsp->ccode) { + lPrintf(LOG_NOTICE, "Get HPM.x Capabilities request failed," + " compcode = %x", rsp->ccode); + return rsp->ccode; + } + + /* check response length */ + if (rsp->data_len < 2 || rsp->data_len > 10) { + lPrintf(LOG_NOTICE, "Bad response length, len=%d", rsp->data_len); + return -1; + } + + /* check HPM.x identifier */ + if (rsp->data[1] != 2) { + lPrintf(LOG_NOTICE, "Bad HPM.x ID, id=%d", rsp->data[1]); + return rsp->ccode; + } + + /* + * this hardly can happen, since completion code is already checked. + * but check for safety + */ + if (rsp->data_len < 4) { + lPrintf(LOG_NOTICE, "Bad response length, len=%d", rsp->data_len); + return -1; + } + + /* copy HPM.2 capabilities */ + memcpy(caps, rsp->data + 2, rsp->data_len - 2); + +#if WORDS_BIGENDIAN + /* swap bytes to convert from little-endian format */ + caps->lan_channel_mask = BSWAP_16(caps->lan_channel_mask); +#endif + + /* check HPM.2 revision */ + if (caps->hpm2_revision_id != HPM2_REVISION) { + lPrintf(LOG_NOTICE, "Bad HPM.2 revision, rev=%d", + caps->hpm2_revision_id); + return -1; + } + + if (!caps->lan_channel_mask) { + return -1; + } + + /* check response length */ + if (rsp->data_len < 8) { + lPrintf(LOG_NOTICE, "Bad response length, len=%d", rsp->data_len); + return -1; + } + + /* check HPM.2 LAN parameters start */ + if (caps->hpm2_lan_params_start < 0xC0) { + lPrintf(LOG_NOTICE, "Bad HPM.2 LAN params start, start=%x", + caps->hpm2_lan_params_start); + return -1; + } + + /* check HPM.2 LAN parameters revision */ + if (caps->hpm2_lan_params_rev != HPM2_LAN_PARAMS_REV) { + lPrintf(LOG_NOTICE, "Bad HPM.2 LAN params revision, rev=%d", + caps->hpm2_lan_params_rev); + return -1; + } + + /* check for HPM.2 SOL extension */ + if (!(caps->hpm2_caps & HPM2_CAPS_SOL_EXTENSION)) { + /* no further checks */ + return 0; + } + + /* check response length */ + if (rsp->data_len < 10) { + lPrintf(LOG_NOTICE, "Bad response length, len=%d", rsp->data_len); + return -1; + } + + /* check HPM.2 SOL parameters start */ + if (caps->hpm2_sol_params_start < 0xC0) { + lPrintf(LOG_NOTICE, "Bad HPM.2 SOL params start, start=%x", + caps->hpm2_sol_params_start); + return -1; + } + + /* check HPM.2 SOL parameters revision */ + if (caps->hpm2_sol_params_rev != HPM2_SOL_PARAMS_REV) { + lPrintf(LOG_NOTICE, "Bad HPM.2 SOL params revision, rev=%d", + caps->hpm2_sol_params_rev); + return -1; + } + + return 0; +} +template <class T> int hpm2_get_lan_channel_capabilities( ipmi_intf<T> * intf, uint8_t hpm2_lan_params_start, - struct hpm2_lan_channel_capabilities * caps); -extern int hpm2_detect_max_payload_size(struct ipmi_intf * intf); + struct hpm2_lan_channel_capabilities * caps) +{ + struct ipmi_rq req; + struct ipmi_rs * rsp; + uint8_t rq[4]; + + /* reset result */ + memset((void*)caps, 0, sizeof(struct hpm2_lan_channel_capabilities)); + + /* prepare request */ + req.zero(); +// memset(&req, 0, sizeof(req)); + req.msg.netfn = IPMI_NETFN_TRANSPORT; + req.msg.cmd = IPMI_LAN_GET_CONFIG; + req.msg.data = (uint8_t *)&rq; + req.msg.data_len = sizeof(rq); + + /* prepare request data */ + rq[0] = 0xE; /* sending channel */ + rq[1] = hpm2_lan_params_start; /* HPM.2 Channel Caps */ + rq[2] = rq[3] = 0; + + /* send */ + rsp = intf->sendrecv( &req); + + if (rsp) { + lPrintf(LOG_NOTICE, "Error sending request"); + return -1; + } + + if (rsp->ccode == 0x80) { + lPrintf(LOG_DEBUG, "HPM.2 Channel Caps parameter is not supported"); + return rsp->ccode; + } else if (rsp->ccode) { + lPrintf(LOG_NOTICE, "Get LAN Configuration Parameters request failed," + " compcode = %x", rsp->ccode); + return rsp->ccode; + } + + /* check response length */ + if (rsp->data_len != sizeof (struct hpm2_lan_channel_capabilities) + 1) { + lPrintf(LOG_NOTICE, "Bad response length, len=%d", rsp->data_len); + return -1; + } + + /* check parameter revision */ + if (rsp->data[0] != + LAN_PARAM_REV(HPM2_LAN_PARAMS_REV, HPM2_LAN_PARAMS_REV)) { + lPrintf(LOG_NOTICE, "Bad HPM.2 LAN parameter revision, rev=%d", + rsp->data[0]); + return -1; + } + + /* copy parameter data */ + memcpy(caps, &rsp->data[1], sizeof (struct hpm2_lan_channel_capabilities)); + +#if WORDS_BIGENDIAN + /* swap bytes to convert from little-endian format */ + caps->max_inbound_pld_size = BSWAP_16(caps->max_inbound_pld_size); + caps->max_outbound_pld_size = BSWAP_16(caps->max_outbound_pld_size); +#endif + + return 0; +} +template <class T> int hpm2_detect_max_payload_size( ipmi_intf<T> * intf) +{ + struct hpm2_lan_attach_capabilities attach_caps; + struct hpm2_lan_channel_capabilities channel_caps; + int err; + + /* query HPM.2 support */ + err = hpm2_get_capabilities(intf, &attach_caps); + + /* check if HPM.2 is supported */ + if (err != 0 || !attach_caps.lan_channel_mask) { + return err; + } + + /* query channel capabilities */ + err = hpm2_get_lan_channel_capabilities(intf, + attach_caps.hpm2_lan_params_start, &channel_caps); + + /* check if succeeded */ + if (err != 0) { + return err; + } + + /* update request and response sizes */ + intf->ipmi_intf_set_max_request_data_size(channel_caps.max_inbound_pld_size - 7); + intf->ipmi_intf_set_max_response_data_size(channel_caps.max_outbound_pld_size - 8); + + /* print debug info */ + lPrintf(LOG_DEBUG, "Set maximum request size to %d\n" + "Set maximum response size to %d", + intf->max_request_data_size, intf->max_response_data_size); + + return 0; +} diff --git a/Online/IPMI/src/NewLib/ipmi.h b/Online/IPMI/src/NewLib/ipmi.h index c7445733554e3bb10dfac5306a3b620d521bc2b6..627ed3f4527b1bb8ac975c02225c1e47d5110a86 100644 --- a/Online/IPMI/src/NewLib/ipmi.h +++ b/Online/IPMI/src/NewLib/ipmi.h @@ -77,6 +77,8 @@ #define IPMI_PAYLOAD_TYPE_RAKP_2 0x13 #define IPMI_PAYLOAD_TYPE_RAKP_3 0x14 #define IPMI_PAYLOAD_TYPE_RAKP_4 0x15 +#define IPMI_BUF_SIZE 1024 +#define IPMI_MAX_MD_SIZE 0x20 extern int verbose; extern int csv_output; @@ -90,6 +92,24 @@ struct ipmi_rq { uint16_t data_len; uint8_t *data; } msg; + ipmi_rq() + { + msg.netfn =0; + msg.lun = 0; + msg.cmd=0; + msg.target_cmd=0; + msg.data_len = 0; + msg.data = 0; + } + void zero() + { + msg.netfn =0; + msg.lun = 0; + msg.cmd=0; + msg.target_cmd=0; + msg.data_len = 0; + msg.data = 0; + } }; /* @@ -154,15 +174,26 @@ struct ipmi_v2_payload { } payload; }; -class ipmi_intf; -struct ipmi_rq_entry { - struct ipmi_rq req; - ipmi_intf *intf; - uint8_t rq_seq; - uint8_t *msg_data; - int msg_len; - int bridging_level; - struct ipmi_rq_entry *next; +template <class G> class ipmi_intf; +template <class T> class ipmi_rq_entry { + public: + struct ipmi_rq req; + ipmi_intf<T> *intf; + uint8_t rq_seq; + uint8_t *msg_data; + int msg_len; + int bridging_level; + ipmi_rq_entry<T> *next; + void zero() + { + req.zero(); + intf = 0; + rq_seq=0; + msg_data=0; + msg_len=0; + bridging_level=0; + next = 0; + } }; struct ipmi_rs { diff --git a/Online/IPMI/src/NewLib/ipmi_cc.h b/Online/IPMI/src/NewLib/ipmi_cc.h new file mode 100755 index 0000000000000000000000000000000000000000..237b1eeafd349fb140aab6c8f178aaeb056a7b08 --- /dev/null +++ b/Online/IPMI/src/NewLib/ipmi_cc.h @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. + * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. + * SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE + * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING + * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL + * SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, + * OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR + * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF + * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, + * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + */ + +#ifndef IPMI_CC_H +#define IPMI_CC_H + +/* + Thu Jan 11 09:32:41 2007 + francois.isabelle@ca.kontron.com + + I just noticed that most modules refer to IPMI completion codes using + hard coded values ... +*/ + +/* + * CC + * See IPMI specification table 5-2 Generic Completion Codes + */ + +#define IPMI_CC_OK 0x00 +#define IPMI_CC_NODE_BUSY 0xc0 +#define IPMI_CC_INV_CMD 0xc1 +#define IPMI_CC_INV_CMD_FOR_LUN 0xc2 +#define IPMI_CC_TIMEOUT 0xc3 +#define IPMI_CC_OUT_OF_SPACE 0xc4 +#define IPMI_CC_RES_CANCELED 0xc5 +#define IPMI_CC_REQ_DATA_TRUNC 0xc6 +#define IPMI_CC_REQ_DATA_INV_LENGTH 0xc7 +#define IPMI_CC_REQ_DATA_FIELD_EXCEED 0xc8 +#define IPMI_CC_PARAM_OUT_OF_RANGE 0xc9 +#define IPMI_CC_CANT_RET_NUM_REQ_BYTES 0xca +#define IPMI_CC_REQ_DATA_NOT_PRESENT 0xcb +#define IPMI_CC_INV_DATA_FIELD_IN_REQ 0xcc +#define IPMI_CC_ILL_SENSOR_OR_RECORD 0xcd +#define IPMI_CC_RESP_COULD_NOT_BE_PRV 0xce +#define IPMI_CC_CANT_RESP_DUPLI_REQ 0xcf +#define IPMI_CC_CANT_RESP_SDRR_UPDATE 0xd0 +#define IPMI_CC_CANT_RESP_FIRM_UPDATE 0xd1 +#define IPMI_CC_CANT_RESP_BMC_INIT 0xd2 +#define IPMI_CC_DESTINATION_UNAVAILABLE 0xd3 +#define IPMI_CC_INSUFFICIENT_PRIVILEGES 0xd4 +#define IPMI_CC_NOT_SUPPORTED_PRESENT_STATE 0xd5 +#define IPMI_CC_ILLEGAL_COMMAND_DISABLED 0xd6 +#define IPMI_CC_UNSPECIFIED_ERROR 0xff + + +#endif /*IPMI_CC_H*/ diff --git a/Online/IPMI/src/NewLib/ipmi_channel.cpp b/Online/IPMI/src/NewLib/ipmi_channel.cpp new file mode 100755 index 0000000000000000000000000000000000000000..d1cc7f7fb0b1583c6ff37f0125d73b67492c3345 --- /dev/null +++ b/Online/IPMI/src/NewLib/ipmi_channel.cpp @@ -0,0 +1,926 @@ +/* -*-mode: C; indent-tabs-mode: t; -*- + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. + * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. + * SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE + * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING + * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL + * SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, + * OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR + * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF + * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, + * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + */ + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <strings.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <errno.h> +#include <unistd.h> +#include <signal.h> + +#include "ipmi.h" +#include "ipmi_intf.h" +#include "helper.h" +#include "log.h" +//#include "ipmi_lanp.h" +#include "ipmi_channel.h" +#include "ipmi_strings.h" +#include "ipmi_constants.h" +#include "ipmi_user.h" +#include "lan.h" +#include "LANPlus.h" +int csv_output; +extern int verbose; + +template <class T> ipmi_channel<T>::ipmi_channel(ipmi_intf<T> *i) +{ + intf = i; + h = new ipmi_helper<T>(); + u = new ipmi_user<T>(i); +} +//void printf_channel_usage(void); + +/* _ipmi_get_channel_access - Get Channel Access for given channel. Results are + * stored into passed struct. + * + * @intf - IPMI interface + * @channel_access - ptr to channel_access_t with Channel set. + * @get_volatile_settings - get volatile if != 0, else non-volatile settings. + * + * returns - negative number means error, positive is a ccode. + */ + +template <class T> int ipmi_channel<T>::_ipmi_get_channel_access(ipmi_intf<T> *intf, + struct channel_access_t *channel_access, + uint8_t get_volatile_settings) +{ + struct ipmi_rs *rsp; + struct ipmi_rq req; + uint8_t data[2]; + + if (channel_access == NULL) { + return (-3); + } + data[0] = channel_access->channel & 0x0F; + /* volatile - 0x80; non-volatile - 0x40 */ + data[1] = get_volatile_settings ? 0x80 : 0x40; + req.msg.netfn = IPMI_NETFN_APP; + req.msg.cmd = IPMI_GET_CHANNEL_ACCESS; + req.msg.data = data; + req.msg.data_len = 2; + + rsp = intf->sendrecv( &req); + if (rsp == NULL) { + return (-1); + } else if (rsp->ccode != 0) { + return rsp->ccode; + } else if (rsp->data_len != 2) { + return (-2); + } + channel_access->alerting = rsp->data[0] & 0x20; + channel_access->per_message_auth = rsp->data[0] & 0x10; + channel_access->user_level_auth = rsp->data[0] & 0x08; + channel_access->access_mode = rsp->data[0] & 0x07; + channel_access->privilege_limit = rsp->data[1] & 0x0F; + return 0; +} + +/* _ipmi_get_channel_info - Get Channel Info for given channel. Results are + * stored into passed struct. + * + * @intf - IPMI interface + * @channel_info - ptr to channel_info_t with Channel set. + * + * returns - negative number means error, positive is a ccode. + */ +template <class T> int ipmi_channel<T>::_ipmi_get_channel_info(ipmi_intf<T> *intf, + struct channel_info_t *channel_info) +{ + struct ipmi_rs *rsp; + struct ipmi_rq req; + uint8_t data[1]; + + if (channel_info == NULL) { + return (-3); + } + data[0] = channel_info->channel & 0x0F; + req.msg.netfn = IPMI_NETFN_APP; + req.msg.cmd = IPMI_GET_CHANNEL_INFO; + req.msg.data = data; + req.msg.data_len = 1; + + rsp = intf->sendrecv(&req); + if (rsp == NULL) { + return (-1); + } else if (rsp->ccode != 0) { + return rsp->ccode; + } else if (rsp->data_len != 9) { + return (-2); + } + channel_info->channel = rsp->data[0] & 0x0F; + channel_info->medium = rsp->data[1] & 0x7F; + channel_info->protocol = rsp->data[2] & 0x1F; + channel_info->session_support = rsp->data[3] & 0xC0; + channel_info->active_sessions = rsp->data[3] & 0x3F; + memcpy(channel_info->vendor_id, &rsp->data[4], + sizeof(channel_info->vendor_id)); + memcpy(channel_info->aux_info, &rsp->data[7], + sizeof(channel_info->aux_info)); + return 0; +} + +/* _ipmi_set_channel_access - Set Channel Access values for given channel. + * + * @intf - IPMI interface + * @channel_access - channel_access_t with desired values and channel set. + * @access_option: + * - 0 = don't set/change Channel Access + * - 1 = set non-volatile settings of Channel Access + * - 2 = set volatile settings of Channel Access + * @privilege_option: + * - 0 = don't set/change Privilege Level Limit + * - 1 = set non-volatile settings of Privilege Limit + * - 2 = set volatile settings of Privilege Limit + * + * returns - negative number means error, positive is a ccode. See IPMI + * specification for further information on ccodes for Set Channel Access. + * 0x82 - set not supported on selected channel, eg. session-less channel. + * 0x83 - access mode not supported + */ +template <class T> int ipmi_channel<T>::_ipmi_set_channel_access(ipmi_intf<T> *intf, + struct channel_access_t channel_access, + uint8_t access_option, + uint8_t privilege_option) +{ + struct ipmi_rs *rsp; + struct ipmi_rq req; + uint8_t data[3]; + /* Only values from <0..2> are accepted as valid. */ + if (access_option > 2 || privilege_option > 2) { + return (-3); + } + + memset(&data, 0, sizeof(data)); + data[0] = channel_access.channel & 0x0F; + data[1] = (access_option << 6); + if (channel_access.alerting) { + data[1] |= 0x20; + } + if (channel_access.per_message_auth) { + data[1] |= 0x10; + } + if (channel_access.user_level_auth) { + data[1] |= 0x08; + } + data[1] |= (channel_access.access_mode & 0x07); + data[2] = (privilege_option << 6); + data[2] |= (channel_access.privilege_limit & 0x0F); + + req.msg.netfn = IPMI_NETFN_APP; + req.msg.cmd = IPMI_SET_CHANNEL_ACCESS; + req.msg.data = data; + req.msg.data_len = 3; + + rsp = intf->sendrecv( &req); + if (rsp == NULL) { + return (-1); + } + return rsp->ccode; +} + +const char *iana_string(uint32_t iana) +{ + static char s[10]; + + if (iana) { + sprintf(s, "%06x", iana); + return s; + } else { + return "N/A"; + } +} + +/** + * ipmi_1_5_authtypes + * + * Create a string describing the supported authentication types as + * specificed by the parameter n + */ +const char *ipmi_1_5_authtypes(uint8_t n) +{ + uint32_t i; + static char supportedTypes[128]; + + memset(supportedTypes, 0, sizeof(supportedTypes)); + for (i = 0; ipmi_authtype_vals[i].val != 0; i++) { + if (n & ipmi_authtype_vals[i].val) { + strcat(supportedTypes, ipmi_authtype_vals[i].str); + strcat(supportedTypes, " "); + } + } + + return supportedTypes; +} + +template <class T> uint8_t ipmi_channel<T>::ipmi_current_channel_medium( ipmi_intf<T> *intf) +{ + return ipmi_get_channel_medium(intf, 0xE); +} + +/** + * ipmi_get_channel_auth_cap + * + * return 0 on success + * -1 on failure + */ +template <class T> int ipmi_channel<T>::ipmi_get_channel_auth_cap( ipmi_intf<T> *intf, uint8_t channel, uint8_t priv) +{ + struct ipmi_rs *rsp; + struct ipmi_rq req; + struct get_channel_auth_cap_rsp auth_cap; + uint8_t msg_data[2]; + + /* Ask for IPMI v2 data as well */ + msg_data[0] = channel | 0x80; + msg_data[1] = priv; + +// memset(&req, 0, sizeof(req)); + req.msg.netfn = IPMI_NETFN_APP; + req.msg.cmd = IPMI_GET_CHANNEL_AUTH_CAP; + req.msg.data = msg_data; + req.msg.data_len = 2; + + rsp = intf->sendrecv( &req); + + if ((rsp == NULL) || (rsp->ccode > 0)) { + /* + * It's very possible that this failed because we asked for IPMI v2 data + * Ask again, without requesting IPMI v2 data + */ + msg_data[0] &= 0x7F; + + rsp = intf->sendrecv( &req); + if (rsp == NULL) { + lPrintf(LOG_ERR, "Unable to Get Channel Authentication Capabilities"); + return (-1); + } + if (rsp->ccode > 0) { + lPrintf(LOG_ERR, "Get Channel Authentication Capabilities failed: %s", + h->val2str(rsp->ccode, completion_code_vals)); + return (-1); + } + } + + memcpy(&auth_cap, rsp->data, sizeof(struct get_channel_auth_cap_rsp)); + + printf("Channel number : %d\n", + auth_cap.channel_number); + printf("IPMI v1.5 auth types : %s\n", + ipmi_1_5_authtypes(auth_cap.enabled_auth_types)); + + if (auth_cap.v20_data_available) { + printf("KG status : %s\n", + (auth_cap.kg_status) ? "non-zero" : "default (all zeroes)"); + } + + printf("Per message authentication : %sabled\n", + (auth_cap.per_message_auth) ? "dis" : "en"); + printf("User level authentication : %sabled\n", + (auth_cap.user_level_auth) ? "dis" : "en"); + + printf("Non-null user names exist : %s\n", + (auth_cap.non_null_usernames) ? "yes" : "no"); + printf("Null user names exist : %s\n", + (auth_cap.null_usernames) ? "yes" : "no"); + printf("Anonymous login enabled : %s\n", + (auth_cap.anon_login_enabled) ? "yes" : "no"); + + if (auth_cap.v20_data_available) { + printf("Channel supports IPMI v1.5 : %s\n", + (auth_cap.ipmiv15_support) ? "yes" : "no"); + printf("Channel supports IPMI v2.0 : %s\n", + (auth_cap.ipmiv20_support) ? "yes" : "no"); + } + + /* + * If there is support for an OEM authentication type, there is some + * information. + */ + if (auth_cap.enabled_auth_types & IPMI_1_5_AUTH_TYPE_BIT_OEM) { + printf("IANA Number for OEM : %d\n", + auth_cap.oem_id[0] | + auth_cap.oem_id[1] << 8 | + auth_cap.oem_id[2] << 16); + printf("OEM Auxiliary Data : 0x%x\n", + auth_cap.oem_aux_data); + } + + return 0; +} + +template <class T> int ipmi_channel<T>::ipmi_get_channel_cipher_suites(ipmi_intf<T> *intf, const char *payload_type, + uint8_t channel) +{ + struct ipmi_rs *rsp; + struct ipmi_rq req; + + uint8_t rqdata[3]; + uint32_t iana; + uint8_t auth_alg, integrity_alg, crypt_alg; + uint8_t cipher_suite_id; + uint8_t list_index = 0; + /* 0x40 sets * 16 bytes per set */ + uint8_t cipher_suite_data[1024]; + uint16_t offset = 0; + /* how much was returned, total */ + uint16_t cipher_suite_data_length = 0; + + memset(cipher_suite_data, 0, sizeof(cipher_suite_data)); + +// memset(&req, 0, sizeof(req)); + req.msg.netfn = IPMI_NETFN_APP; + req.msg.cmd = IPMI_GET_CHANNEL_CIPHER_SUITES; + req.msg.data = rqdata; + req.msg.data_len = 3; + + rqdata[0] = channel; + rqdata[1] = ((strncmp(payload_type, "ipmi", 4) == 0)? 0: 1); + /* Always ask for cipher suite format */ + rqdata[2] = 0x80; + + rsp = intf->sendrecv( &req); + if (rsp == NULL) { + lPrintf(LOG_ERR, "Unable to Get Channel Cipher Suites"); + return -1; + } + if (rsp->ccode > 0) { + lPrintf(LOG_ERR, "Get Channel Cipher Suites failed: %s", + h->val2str(rsp->ccode, completion_code_vals)); + return -1; + } + + + /* + * Grab the returned channel number once. We assume it's the same + * in future calls. + */ + if (rsp->data_len >= 1) { + channel = rsp->data[0]; + } + + while ((rsp->data_len > 1) && (rsp->data_len == 17) && (list_index < 0x3F)) { + /* + * We got back cipher suite data -- store it. + * printf("copying data to offset %d\n", offset); + * printbuf(rsp->data + 1, rsp->data_len - 1, "this is the data"); + */ + memcpy(cipher_suite_data + offset, rsp->data + 1, rsp->data_len - 1); + offset += rsp->data_len - 1; + + /* + * Increment our list for the next call + */ + ++list_index; + rqdata[2] = (rqdata[2] & 0x80) + list_index; + + rsp = intf->sendrecv( &req); + if (rsp == NULL) { + lPrintf(LOG_ERR, "Unable to Get Channel Cipher Suites"); + return -1; + } + if (rsp->ccode > 0) { + lPrintf(LOG_ERR, "Get Channel Cipher Suites failed: %s", + h->val2str(rsp->ccode, completion_code_vals)); + return -1; + } + } + + /* Copy last chunk */ + if(rsp->data_len > 1) { + /* + * We got back cipher suite data -- store it. + * printf("copying data to offset %d\n", offset); + * printbuf(rsp->data + 1, rsp->data_len - 1, "this is the data"); + */ + memcpy(cipher_suite_data + offset, rsp->data + 1, rsp->data_len - 1); + offset += rsp->data_len - 1; + } + + /* We can chomp on all our data now. */ + cipher_suite_data_length = offset; + offset = 0; + + if (! csv_output) { + printf("ID IANA Auth Alg Integrity Alg Confidentiality Alg\n"); + } + while (offset < cipher_suite_data_length) { + if (cipher_suite_data[offset++] == 0xC0) { + /* standard type */ + iana = 0; + + /* Verify that we have at least a full record left; id + 3 algs */ + if ((cipher_suite_data_length - offset) < 4) { + lPrintf(LOG_ERR, "Incomplete data record in cipher suite data"); + return -1; + } + cipher_suite_id = cipher_suite_data[offset++]; + } else if (cipher_suite_data[offset++] == 0xC1) { + /* OEM record type */ + /* Verify that we have at least a full record left + * id + iana + 3 algs + */ + if ((cipher_suite_data_length - offset) < 4) { + lPrintf(LOG_ERR, "Incomplete data record in cipher suite data"); + return -1; + } + + cipher_suite_id = cipher_suite_data[offset++]; + + /* Grab the IANA */ + iana = + cipher_suite_data[offset] | + (cipher_suite_data[offset + 1] << 8) | + (cipher_suite_data[offset + 2] << 16); + offset += 3; + } else { + lPrintf(LOG_ERR, "Bad start of record byte in cipher suite data"); + return -1; + } + + /* + * Grab the algorithms for this cipher suite. I guess we can't be + * sure of what order they'll come in. Also, I suppose we default + * to the NONE algorithm if one were absent. This part of the spec is + * poorly written -- I have read the errata document. For now, I'm only + * allowing one algorithm per type (auth, integrity, crypt) because I + * don't I understand how it could be otherwise. + */ + auth_alg = IPMI_AUTH_RAKP_NONE; + integrity_alg = IPMI_INTEGRITY_NONE; + crypt_alg = IPMI_CRYPT_NONE; + + while (((cipher_suite_data[offset] & 0xC0) != 0xC0) && + ((cipher_suite_data_length - offset) > 0)) + { + switch (cipher_suite_data[offset] & 0xC0) + { + case 0x00: + /* Authentication algorithm specifier */ + auth_alg = cipher_suite_data[offset++] & 0x3F; + break; + case 0x40: + /* Interity algorithm specifier */ + integrity_alg = cipher_suite_data[offset++] & 0x3F; + break; + case 0x80: + /* Confidentiality algorithm specifier */ + crypt_alg = cipher_suite_data[offset++] & 0x3F; + break; + } + } + /* We have everything we need to spit out a cipher suite record */ + printf((csv_output? "%d,%s,%s,%s,%s\n" : + "%-4d %-7s %-15s %-15s %-15s\n"), + cipher_suite_id, + iana_string(iana), + h->val2str(auth_alg, ipmi_auth_algorithms), + h->val2str(integrity_alg, ipmi_integrity_algorithms), + h->val2str(crypt_alg, ipmi_encryption_algorithms)); + } + return 0; +} + +/** + * ipmi_get_channel_info + * + * returns 0 on success + * -1 on failure + * + */ +template <class T> int ipmi_channel<T>::ipmi_get_channel_info(ipmi_intf<T> *intf, uint8_t channel) +{ + struct channel_info_t channel_info; + struct channel_access_t channel_access; + int ccode = 0; + + channel_info.channel = channel; + ccode = _ipmi_get_channel_info(intf, &channel_info); + if (h->eval_ccode(ccode) != 0) { + lPrintf(LOG_ERR, "Unable to Get Channel Info"); + return (-1); + } + + printf("Channel 0x%x info:\n", channel_info.channel); + printf(" Channel Medium Type : %s\n", + h->val2str(channel_info.medium, + ipmi_channel_medium_vals)); + printf(" Channel Protocol Type : %s\n", + h->val2str(channel_info.protocol, + ipmi_channel_protocol_vals)); + printf(" Session Support : "); + switch (channel_info.session_support) { + case IPMI_CHANNEL_SESSION_LESS: + printf("session-less\n"); + break; + case IPMI_CHANNEL_SESSION_SINGLE: + printf("single-session\n"); + break; + case IPMI_CHANNEL_SESSION_MULTI: + printf("multi-session\n"); + break; + case IPMI_CHANNEL_SESSION_BASED: + printf("session-based\n"); + break; + default: + printf("unknown\n"); + break; + } + printf(" Active Session Count : %d\n", + channel_info.active_sessions); + printf(" Protocol Vendor ID : %d\n", + channel_info.vendor_id[0] | + channel_info.vendor_id[1] << 8 | + channel_info.vendor_id[2] << 16); + + /* only proceed if this is LAN channel */ + if (channel_info.medium != IPMI_CHANNEL_MEDIUM_LAN + && channel_info.medium != IPMI_CHANNEL_MEDIUM_LAN_OTHER) { + return 0; + } + + channel_access.channel = channel_info.channel; + ccode = _ipmi_get_channel_access(intf, &channel_access, 1); + if (h->eval_ccode(ccode) != 0) { + lPrintf(LOG_ERR, "Unable to Get Channel Access (volatile)"); + return (-1); + } + + printf(" Volatile(active) Settings\n"); + printf(" Alerting : %sabled\n", + (channel_access.alerting) ? "dis" : "en"); + printf(" Per-message Auth : %sabled\n", + (channel_access.per_message_auth) ? "dis" : "en"); + printf(" User Level Auth : %sabled\n", + (channel_access.user_level_auth) ? "dis" : "en"); + printf(" Access Mode : "); + switch (channel_access.access_mode) { + case 0: + printf("disabled\n"); + break; + case 1: + printf("pre-boot only\n"); + break; + case 2: + printf("always available\n"); + break; + case 3: + printf("shared\n"); + break; + default: + printf("unknown\n"); + break; + } + +// memset(&channel_access, 0, sizeof(channel_access)); + channel_access.channel = channel_info.channel; + /* get non-volatile settings */ + ccode = _ipmi_get_channel_access(intf, &channel_access, 0); + if (h->eval_ccode(ccode) != 0) { + lPrintf(LOG_ERR, "Unable to Get Channel Access (non-volatile)"); + return (-1); + } + + printf(" Non-Volatile Settings\n"); + printf(" Alerting : %sabled\n", + (channel_access.alerting) ? "dis" : "en"); + printf(" Per-message Auth : %sabled\n", + (channel_access.per_message_auth) ? "dis" : "en"); + printf(" User Level Auth : %sabled\n", + (channel_access.user_level_auth) ? "dis" : "en"); + printf(" Access Mode : "); + switch (channel_access.access_mode) { + case 0: + printf("disabled\n"); + break; + case 1: + printf("pre-boot only\n"); + break; + case 2: + printf("always available\n"); + break; + case 3: + printf("shared\n"); + break; + default: + printf("unknown\n"); + break; + } + return 0; +} + +/* ipmi_get_channel_medium - Return Medium of given IPMI Channel. + * + * @channel - IPMI Channel + * + * returns - IPMI Channel Medium, IPMI_CHANNEL_MEDIUM_RESERVED if ccode > 0, + * 0 on error. + */ +template <class T> uint8_t ipmi_channel<T>::ipmi_get_channel_medium(ipmi_intf<T> *intf, uint8_t channel) +{ + struct channel_info_t channel_info = {0}; + int ccode = 0; + + channel_info.channel = channel; + ccode = _ipmi_get_channel_info(intf, &channel_info); + if (ccode == 0xCC) { + return IPMI_CHANNEL_MEDIUM_RESERVED; + } else if (ccode < 0 && h->eval_ccode(ccode) != 0) { + return 0; + } else if (ccode > 0) { + lPrintf(LOG_ERR, "Get Channel Info command failed: %s", + h->val2str(ccode, completion_code_vals)); + return IPMI_CHANNEL_MEDIUM_RESERVED; + } + lPrintf(LOG_DEBUG, "Channel type: %s", + h->val2str(channel_info.medium, ipmi_channel_medium_vals)); + return channel_info.medium; +} + +/* ipmi_get_user_access - Get User Access for given Channel and User or Users. + * + * @intf - IPMI interface + * @channel - IPMI Channel we're getting access for + * @user_id - User ID. If 0 is passed, all IPMI users will be listed + * + * returns - 0 on success, (-1) on error + */ +template <class T> int ipmi_channel<T>::get_user_access( uint8_t channel, uint8_t user_id) +{ + struct user_access_t user_access; + struct user_name_t user_name; + int ccode = 0; + int curr_uid; + int init = 1; + int max_uid = 0; + + curr_uid = user_id ? user_id : 1; + do { + user_access.zero(); + user_access.channel = channel; + user_access.user_id = curr_uid; + ccode = u->get_user_access( &user_access); + if (h->eval_ccode(ccode) != 0) { + lPrintf(LOG_ERR, + "Unable to Get User Access (channel %d id %d)", + channel, curr_uid); + return (-1); + } + user_name.zero(); + user_name.user_id = curr_uid; + ccode = u->get_user_name( &user_name); + if (ccode == 0xCC) { + user_name.user_id = curr_uid; + memset(&user_name.user_name, '\0', 17); + } else if (h->eval_ccode(ccode) != 0) { + lPrintf(LOG_ERR, "Unable to Get User Name (id %d)", curr_uid); + return (-1); + } + if (init) { + printf("Maximum User IDs : %d\n", user_access.max_user_ids); + printf("Enabled User IDs : %d\n", user_access.enabled_user_ids); + max_uid = user_access.max_user_ids; + init = 0; + } + + printf("\n"); + printf("User ID : %d\n", curr_uid); + printf("User Name : %s\n", user_name.user_name); + printf("Fixed Name : %s\n", + (curr_uid <= user_access.fixed_user_ids) ? "Yes" : "No"); + printf("Access Available : %s\n", + (user_access.callin_callback) ? "callback" : "call-in / callback"); + printf("Link Authentication : %sabled\n", + (user_access.link_auth) ? "en" : "dis"); + printf("IPMI Messaging : %sabled\n", + (user_access.ipmi_messaging) ? "en" : "dis"); + printf("Privilege Level : %s\n", + h->val2str(user_access.privilege_limit, ipmi_privlvl_vals)); + printf("Enable Status : %s\n", + h->val2str(user_access.enable_status, ipmi_user_enable_status_vals)); + curr_uid ++; + } while (!user_id && curr_uid <= max_uid); + + return 0; +} + +/* ipmi_set_user_access - Query BMC for current Channel ACLs, parse CLI args + * and update current ACLs. + * + * returns - 0 on success, (-1) on error + */ +template <class T> int ipmi_channel<T>::set_user_access( int argc, char **argv) +{ + struct user_access_t user_access = {0}; + int ccode = 0; + int i = 0; + uint8_t channel = 0; + uint8_t priv = 0; + uint8_t user_id = 0; + if (argc > 0 && strncmp(argv[0], "help", 4) == 0) { + printf_channel_usage(); + return 0; + } else if (argc < 3) { + lPrintf(LOG_ERR, "Not enough parameters given."); + printf_channel_usage(); + return (-1); + } + if (h->is_ipmi_channel_num(argv[0], &channel) != 0 + || h->is_ipmi_user_id(argv[1], &user_id) != 0) { + return (-1); + } + user_access.channel = channel; + user_access.user_id = user_id; + ccode = u->get_user_access( &user_access); + if (h->eval_ccode(ccode) != 0) { + lPrintf(LOG_ERR, + "Unable to Get User Access (channel %d id %d)", + channel, user_id); + return (-1); + } + for (i = 2; i < argc; i ++) { + if (strncmp(argv[i], "callin=", 7) == 0) { + if (strncmp(argv[i] + 7, "off", 3) == 0) { + user_access.callin_callback = 1; + } else { + user_access.callin_callback = 0; + } + } else if (strncmp(argv[i], "link=", 5) == 0) { + if (strncmp(argv[i] + 5, "off", 3) == 0) { + user_access.link_auth = 0; + } else { + user_access.link_auth = 1; + } + } else if (strncmp(argv[i], "ipmi=", 5) == 0) { + if (strncmp(argv[i] + 5, "off", 3) == 0) { + user_access.ipmi_messaging = 0; + } else { + user_access.ipmi_messaging = 1; + } + } else if (strncmp(argv[i], "privilege=", 10) == 0) { + if (h->str2uchar(argv[i] + 10, &priv) != 0) { + lPrintf(LOG_ERR, + "Numeric value expected, but '%s' given.", + argv[i] + 10); + return (-1); + } + user_access.privilege_limit = priv; + } else { + lPrintf(LOG_ERR, "Invalid option: %s\n", argv[i]); + return (-1); + } + } + ccode = u->set_user_access( &user_access, 0); + if (h->eval_ccode(ccode) != 0) { + lPrintf(LOG_ERR, + "Unable to Set User Access (channel %d id %d)", + channel, user_id); + return (-1); + } + printf("Set User Access (channel %d id %d) successful.\n", + channel, user_id); + return 0; +} + +template <class T> int ipmi_channel<T>::ipmi_channel_main(ipmi_intf<T> *intf, int argc, char **argv) +{ + int retval = 0; + uint8_t channel; + uint8_t priv = 0; + if (argc < 1) { + lPrintf(LOG_ERR, "Not enough parameters given."); + printf_channel_usage(); + return (-1); + } else if (strncmp(argv[0], "help", 4) == 0) { + printf_channel_usage(); + return 0; + } else if (strncmp(argv[0], "authcap", 7) == 0) { + if (argc != 3) { + printf_channel_usage(); + return (-1); + } + if (h->is_ipmi_channel_num(argv[1], &channel) != 0 + || h->is_ipmi_user_priv_limit(argv[2], &priv) != 0) { + return (-1); + } + retval = ipmi_get_channel_auth_cap(intf, channel, priv); + } else if (strncmp(argv[0], "getaccess", 10) == 0) { + uint8_t user_id = 0; + if ((argc < 2) || (argc > 3)) { + lPrintf(LOG_ERR, "Not enough parameters given."); + printf_channel_usage(); + return (-1); + } + if (h->is_ipmi_channel_num(argv[1], &channel) != 0) { + return (-1); + } + if (argc == 3) { + if (h->is_ipmi_user_id(argv[2], &user_id) != 0) { + return (-1); + } + } + retval = get_user_access( channel, user_id); + } else if (strncmp(argv[0], "setaccess", 9) == 0) { + return set_user_access( (argc - 1), &(argv[1])); + } else if (strncmp(argv[0], "info", 4) == 0) { + channel = 0xE; + if (argc > 2) { + printf_channel_usage(); + return (-1); + } + if (argc == 2) { + if (h->is_ipmi_channel_num(argv[1], &channel) != 0) { + return (-1); + } + } + retval = ipmi_get_channel_info(intf, channel); + } else if (strncmp(argv[0], "getciphers", 10) == 0) { + /* channel getciphers <ipmi|sol> [channel] */ + channel = 0xE; + if ((argc < 2) || (argc > 3) || + (strncmp(argv[1], "ipmi", 4) && strncmp(argv[1], "sol", 3))) { + printf_channel_usage(); + return (-1); + } + if (argc == 3) { + if (h->is_ipmi_channel_num(argv[2], &channel) != 0) { + return (-1); + } + } + retval = ipmi_get_channel_cipher_suites(intf, + argv[1], /* ipmi | sol */ + channel); + } else { + lPrintf(LOG_ERR, "Invalid CHANNEL command: %s\n", argv[0]); + printf_channel_usage(); + retval = -1; + } + return retval; +} + +/* printf_channel_usage - print-out help. */ +void printf_channel_usage() +{ + lPrintf(LOG_NOTICE, +"Channel Commands: authcap <channel number> <max privilege>"); + lPrintf(LOG_NOTICE, +" getaccess <channel number> [user id]"); + lPrintf(LOG_NOTICE, +" setaccess <channel number> " +"<user id> [callin=on|off] [ipmi=on|off] [link=on|off] [privilege=level]"); + lPrintf(LOG_NOTICE, +" info [channel number]"); + lPrintf(LOG_NOTICE, +" getciphers <ipmi | sol> [channel]"); + lPrintf(LOG_NOTICE, +""); + lPrintf(LOG_NOTICE, +"Possible privilege levels are:"); + lPrintf(LOG_NOTICE, +" 1 Callback level"); + lPrintf(LOG_NOTICE, +" 2 User level"); + lPrintf(LOG_NOTICE, +" 3 Operator level"); + lPrintf(LOG_NOTICE, +" 4 Administrator level"); + lPrintf(LOG_NOTICE, +" 5 OEM Proprietary level"); + lPrintf(LOG_NOTICE, +" 15 No access"); +} +template class ipmi_channel<lan>; +template class ipmi_channel<LANPlus>; diff --git a/Online/IPMI/src/NewLib/ipmi_channel.h b/Online/IPMI/src/NewLib/ipmi_channel.h new file mode 100755 index 0000000000000000000000000000000000000000..79698012d357d79440ee9751aaca09dc8fa7087e --- /dev/null +++ b/Online/IPMI/src/NewLib/ipmi_channel.h @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. + * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. + * SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE + * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING + * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL + * SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, + * OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR + * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF + * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, + * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + */ + +#ifndef IPMI_CHANNEL_H +#define IPMI_CHANNEL_H + +#if HAVE_CONFIG_H +# include "config.h" +#endif +#include "ipmi.h" + + +#define IPMI_GET_CHANNEL_AUTH_CAP 0x38 +#define IPMI_SET_CHANNEL_ACCESS 0x40 +#define IPMI_GET_CHANNEL_ACCESS 0x41 +#define IPMI_GET_CHANNEL_INFO 0x42 +#define IPMI_SET_USER_ACCESS 0x43 +#define IPMI_GET_USER_ACCESS 0x44 +#define IPMI_SET_USER_NAME 0x45 +#define IPMI_GET_USER_NAME 0x46 +#define IPMI_SET_USER_PASSWORD 0x47 +#define IPMI_GET_CHANNEL_CIPHER_SUITES 0x54 + +/* These are for channel_info_t.session_support */ +#define IPMI_CHANNEL_SESSION_LESS 0x00 +#define IPMI_CHANNEL_SESSION_SINGLE 0x40 +#define IPMI_CHANNEL_SESSION_MULTI 0x80 +#define IPMI_CHANNEL_SESSION_BASED 0xC0 + +/* (22.24) Get Channel Info */ +struct channel_info_t { + uint8_t channel=0; + uint8_t medium=0; + uint8_t protocol=0; + uint8_t session_support=0; + uint8_t active_sessions=0; + uint8_t vendor_id[3]={0,0,0}; + uint8_t aux_info[2]={0,0}; +}; + +/* (22.23) Get Channel Access */ +struct channel_access_t { + uint8_t access_mode=0; + uint8_t alerting=0; + uint8_t channel=0; + uint8_t per_message_auth=0; + uint8_t privilege_limit=0; + uint8_t user_level_auth=0; +}; + +/* + * The Get Authentication Capabilities response structure + * From table 22-15 of the IPMI v2.0 spec + */ +#ifdef HAVE_PRAGMA_PACK +#pragma pack(1) +#endif +struct get_channel_auth_cap_rsp { + uint8_t channel_number; +#if WORDS_BIGENDIAN + uint8_t v20_data_available : 1; /* IPMI v2.0 data is available */ + uint8_t __reserved1 : 1; + uint8_t enabled_auth_types : 6; /* IPMI v1.5 enabled auth types */ +#else + uint8_t enabled_auth_types : 6; /* IPMI v1.5 enabled auth types */ + uint8_t __reserved1 : 1; + uint8_t v20_data_available : 1; /* IPMI v2.0 data is available */ +#endif +#if WORDS_BIGENDIAN + uint8_t __reserved2 : 2; + uint8_t kg_status : 1; /* two-key login status */ + uint8_t per_message_auth : 1; /* per-message authentication status */ + uint8_t user_level_auth : 1; /* user-level authentication status */ + uint8_t non_null_usernames : 1; /* one or more non-null users exist */ + uint8_t null_usernames : 1; /* one or more null usernames non-null pwds */ + uint8_t anon_login_enabled : 1; /* a null-named, null-pwd user exists */ +#else + uint8_t anon_login_enabled : 1; /* a null-named, null-pwd user exists */ + uint8_t null_usernames : 1; /* one or more null usernames non-null pwds */ + uint8_t non_null_usernames : 1; /* one or more non-null users exist */ + uint8_t user_level_auth : 1; /* user-level authentication status */ + uint8_t per_message_auth : 1; /* per-message authentication status */ + uint8_t kg_status : 1; /* two-key login status */ + uint8_t __reserved2 : 2; +#endif +#if WORDS_BIGENDIAN + uint8_t __reserved3 : 6; + uint8_t ipmiv20_support : 1; /* channel supports IPMI v2.0 connections */ + uint8_t ipmiv15_support : 1; /* channel supports IPMI v1.5 connections */ +#else + uint8_t ipmiv15_support : 1; /* channel supports IPMI v1.5 connections */ + uint8_t ipmiv20_support : 1; /* channel supports IPMI v2.0 connections */ + uint8_t __reserved3 : 6; +#endif + uint8_t oem_id[3]; /* IANA enterprise number for auth type */ + uint8_t oem_aux_data; /* Additional OEM specific data for oem auths */ +} ATTRIBUTE_PACKING; +#ifdef HAVE_PRAGMA_PACK +#pragma pack(0) +#endif +template <class T> class ipmi_intf; +template <class T> class ipmi_user; +template <class T> class ipmi_channel +{ + public: + ipmi_intf<T> *intf; + ipmi_helper<T> *h; + ipmi_user<T> *u; + ipmi_channel(ipmi_intf<T> *i); + int _ipmi_get_channel_access(ipmi_intf<T> *intf, + struct channel_access_t *channel_access, + uint8_t get_volatile_settings); + int _ipmi_get_channel_info( ipmi_intf<T> *intf, + struct channel_info_t *channel_info); + int _ipmi_set_channel_access( ipmi_intf<T> *intf, + struct channel_access_t channel_access, uint8_t access_option, + uint8_t privilege_option); + + uint8_t ipmi_get_channel_medium( ipmi_intf<T> * intf, uint8_t channel); + uint8_t ipmi_current_channel_medium( ipmi_intf<T> * intf); + int ipmi_channel_main( ipmi_intf<T> * intf, int argc, char ** argv); + int ipmi_get_channel_auth_cap( ipmi_intf<T> * intf, uint8_t channel, uint8_t priv); + int ipmi_get_channel_info( ipmi_intf<T> * intf, uint8_t channel); + int ipmi_get_channel_cipher_suites(ipmi_intf<T> *intf, const char *payload_type, + uint8_t channel); + int get_user_access( uint8_t channel, uint8_t user_id); + int set_user_access( int argc, char **argv); +}; +void printf_channel_usage(void); +#endif /*IPMI_CHANNEL_H*/ diff --git a/Online/IPMI/src/NewLib/ipmi_chassis.cpp b/Online/IPMI/src/NewLib/ipmi_chassis.cpp index ce2266151812f33c9950813bf80fb7cac1416d6e..547cac4c1254e6dc917c65726dce62d4df7494b0 100644 --- a/Online/IPMI/src/NewLib/ipmi_chassis.cpp +++ b/Online/IPMI/src/NewLib/ipmi_chassis.cpp @@ -56,9 +56,9 @@ #include "ipmi_constants.h" //#include "ipmi_strings.h" #include "log.h" +#include "ipmi_chassis.h" #include "helper.h" #include "ipmi_intf.h" -#include "ipmi_chassis.h" #include "ipmi_strings.h" extern int verbose; //valstr ipmi_chassis_power_control_vals[] = { @@ -71,16 +71,16 @@ extern int verbose; // valstr( 0x00, NULL ) //}; -ipmi_chassis::ipmi_chassis(ipmi_intf *i) +template <class T> ipmi_chassis<T>::ipmi_chassis(ipmi_intf<T> *i) { intf = i; } -int ipmi_chassis::ipmi_chassis_power_status() +template <class T> int ipmi_chassis<T>::ipmi_chassis_power_status() { struct ipmi_rs * rsp; struct ipmi_rq req; - - memset(&req, 0, sizeof(req)); + req.zero(); +// memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_CHASSIS; req.msg.cmd = 0x1; req.msg.data_len = 0; @@ -99,7 +99,7 @@ int ipmi_chassis::ipmi_chassis_power_status() return rsp->data[0] & 1; } -int ipmi_chassis::ipmi_chassis_print_power_status() +template <class T> int ipmi_chassis<T>::ipmi_chassis_print_power_status() { int ps = ipmi_chassis_power_status(); @@ -111,12 +111,13 @@ int ipmi_chassis::ipmi_chassis_print_power_status() return ps; } -int ipmi_chassis::ipmi_chassis_power_control( uint8_t ctl) +template <class T> int ipmi_chassis<T>::ipmi_chassis_power_control( uint8_t ctl) { struct ipmi_rs * rsp; struct ipmi_rq req; + req.zero(); - memset(&req, 0, sizeof(req)); +// memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_CHASSIS; req.msg.cmd = 0x2; req.msg.data = &ctl; @@ -146,7 +147,7 @@ int ipmi_chassis::ipmi_chassis_power_control( uint8_t ctl) return 0; } -int ipmi_chassis::ipmi_chassis_identify( char * arg) +template <class T> int ipmi_chassis<T>::ipmi_chassis_identify( char * arg) { struct ipmi_rq req; struct ipmi_rs * rsp; @@ -156,8 +157,9 @@ int ipmi_chassis::ipmi_chassis_identify( char * arg) uint8_t interval; uint8_t force_on; } identify_data = { 0, 0 }; + req.zero(); - memset(&req, 0, sizeof(req)); +// memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_CHASSIS; req.msg.cmd = 0x4; @@ -217,7 +219,7 @@ int ipmi_chassis::ipmi_chassis_identify( char * arg) return 0; } -int ipmi_chassis::ipmi_chassis_poh() +template <class T> int ipmi_chassis<T>::ipmi_chassis_poh() { struct ipmi_rs * rsp; struct ipmi_rq req; @@ -225,8 +227,9 @@ int ipmi_chassis::ipmi_chassis_poh() uint32_t count; float minutes; uint32_t days, hours; + req.zero(); - memset(&req, 0, sizeof(req)); +// memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_CHASSIS; req.msg.cmd = 0xf; @@ -263,12 +266,13 @@ int ipmi_chassis::ipmi_chassis_poh() return 0; } -int ipmi_chassis::ipmi_chassis_restart_cause() +template <class T> int ipmi_chassis<T>::ipmi_chassis_restart_cause() { struct ipmi_rs * rsp; struct ipmi_rq req; - memset(&req, 0, sizeof(req)); + req.zero(); +// memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_CHASSIS; req.msg.cmd = 0x7; @@ -323,12 +327,13 @@ int ipmi_chassis::ipmi_chassis_restart_cause() return 0; } -int ipmi_chassis::ipmi_chassis_status() +template <class T> int ipmi_chassis<T>::ipmi_chassis_status() { struct ipmi_rs * rsp; struct ipmi_rq req; - memset(&req, 0, sizeof(req)); + req.zero(); +// memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_CHASSIS; req.msg.cmd = 0x1; @@ -405,12 +410,13 @@ int ipmi_chassis::ipmi_chassis_status() } -int ipmi_chassis::ipmi_chassis_selftest() +template <class T> int ipmi_chassis<T>::ipmi_chassis_selftest() { struct ipmi_rs * rsp; struct ipmi_rq req; - memset(&req, 0, sizeof(req)); + req.zero(); +// memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_APP; req.msg.cmd = 0x4; @@ -472,7 +478,7 @@ int ipmi_chassis::ipmi_chassis_selftest() return 0; } -int ipmi_chassis::ipmi_chassis_set_bootparam( uint8_t param, uint8_t * data, int len) +template <class T> int ipmi_chassis<T>::ipmi_chassis_set_bootparam( uint8_t param, uint8_t * data, int len) { struct ipmi_rs * rsp; struct ipmi_rq req; @@ -482,7 +488,8 @@ int ipmi_chassis::ipmi_chassis_set_bootparam( uint8_t param, uint8_t * data, int msg_data[0] = param & 0x7f; memcpy(msg_data+1, data, len); - memset(&req, 0, sizeof(req)); + req.zero(); +// memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_CHASSIS; req.msg.cmd = 0x8; req.msg.data = msg_data; @@ -505,7 +512,7 @@ int ipmi_chassis::ipmi_chassis_set_bootparam( uint8_t param, uint8_t * data, int return 0; } -int ipmi_chassis::ipmi_chassis_get_bootparam( char * arg) +template <class T> int ipmi_chassis<T>::ipmi_chassis_get_bootparam( char * arg) { struct ipmi_rs * rsp; struct ipmi_rq req; @@ -527,7 +534,8 @@ int ipmi_chassis::ipmi_chassis_get_bootparam( char * arg) msg_data[1] = 0; msg_data[2] = 0; - memset(&req, 0, sizeof(req)); + req.zero(); +// memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_CHASSIS; req.msg.cmd = 0x9; req.msg.data = msg_data; @@ -774,7 +782,7 @@ int ipmi_chassis::ipmi_chassis_get_bootparam( char * arg) return 0; } -int ipmi_chassis::get_bootparam_options(char *optstring, unsigned char *set_flag, unsigned char *clr_flag) +template <class T> int ipmi_chassis<T>::get_bootparam_options(char *optstring, unsigned char *set_flag, unsigned char *clr_flag) { char *token; char *saveptr = NULL; @@ -849,7 +857,7 @@ int ipmi_chassis::get_bootparam_options(char *optstring, unsigned char *set_flag return (0); } -int ipmi_chassis::ipmi_chassis_get_bootvalid() +template <class T> int ipmi_chassis<T>::ipmi_chassis_get_bootvalid() { struct ipmi_rs * rsp; struct ipmi_rq req; @@ -861,7 +869,8 @@ int ipmi_chassis::ipmi_chassis_get_bootvalid() msg_data[1] = 0; msg_data[2] = 0; - memset(&req, 0, sizeof(req)); + req.zero(); +// memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_CHASSIS; req.msg.cmd = 0x9; req.msg.data = msg_data; @@ -885,7 +894,7 @@ int ipmi_chassis::ipmi_chassis_get_bootvalid() return(rsp->data[2]); } -int ipmi_chassis::ipmi_chassis_set_bootvalid( uint8_t set_flag, uint8_t clr_flag) +template <class T> int ipmi_chassis<T>::ipmi_chassis_set_bootvalid( uint8_t set_flag, uint8_t clr_flag) { int bootvalid; uint8_t flags[5]; @@ -952,7 +961,7 @@ int ipmi_chassis::ipmi_chassis_set_bootvalid( uint8_t set_flag, uint8_t clr_flag return rc; } -int ipmi_chassis::ipmi_chassis_set_bootdev( char * arg, uint8_t *iflags) +template <class T> int ipmi_chassis<T>::ipmi_chassis_set_bootdev( char * arg, uint8_t *iflags) { uint8_t flags[5]; int rc = 0; @@ -1055,12 +1064,13 @@ int ipmi_chassis::ipmi_chassis_set_bootdev( char * arg, uint8_t *iflags) return rc; } -int ipmi_chassis::ipmi_chassis_power_policy( uint8_t policy) +template <class T> int ipmi_chassis<T>::ipmi_chassis_power_policy( uint8_t policy) { struct ipmi_rs * rsp; struct ipmi_rq req; - memset(&req, 0, sizeof(req)); + req.zero(); +// memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_CHASSIS; req.msg.cmd = 0x6; req.msg.data = &policy; @@ -1106,7 +1116,7 @@ int ipmi_chassis::ipmi_chassis_power_policy( uint8_t policy) return 0; } -int ipmi_chassis::ipmi_power_main(int argc, char ** argv) +template <class T> int ipmi_chassis<T>::ipmi_power_main(int argc, char ** argv) { int rc = 0; uint8_t ctl = 0; @@ -1140,7 +1150,7 @@ int ipmi_chassis::ipmi_power_main(int argc, char ** argv) return rc; } -void ipmi_chassis::ipmi_chassis_set_bootflag_help() +template <class T> void ipmi_chassis<T>::ipmi_chassis_set_bootflag_help() { unsigned char set_flag; unsigned char clr_flag; @@ -1156,7 +1166,7 @@ void ipmi_chassis::ipmi_chassis_set_bootflag_help() get_bootparam_options((char*)"options=help", &set_flag, &clr_flag); } -int ipmi_chassis::ipmi_chassis_main( int argc, char ** argv) +template <class T> int ipmi_chassis<T>::ipmi_chassis_main( int argc, char ** argv) { int rc = 0; @@ -1396,3 +1406,7 @@ int ipmi_chassis::ipmi_chassis_main( int argc, char ** argv) return rc; } +#include "lan.h" +#include "LANPlus.h" +template class ipmi_chassis<lan>; +template class ipmi_chassis<LANPlus>; diff --git a/Online/IPMI/src/NewLib/ipmi_chassis.h b/Online/IPMI/src/NewLib/ipmi_chassis.h index 944f6b619de65686fdabe8cef0af920d270f6054..5b2d3fd3e6111bd7ebc3348bc4cf6b4fe26d93fa 100644 --- a/Online/IPMI/src/NewLib/ipmi_chassis.h +++ b/Online/IPMI/src/NewLib/ipmi_chassis.h @@ -71,12 +71,12 @@ //int ipmi_chassis_main(struct ipmi_intf * intf, int argc, char ** argv); //int ipmi_power_main(struct ipmi_intf * intf, int argc, char ** argv); -class ipmi_intf; -class ipmi_chassis +template <class G> class ipmi_intf; +template <class T> class ipmi_chassis { public: - ipmi_intf *intf; - ipmi_chassis (ipmi_intf *); + ipmi_intf<T> *intf; + ipmi_chassis (ipmi_intf<T> *); int ipmi_chassis_power_status(); int ipmi_chassis_print_power_status( ); int ipmi_chassis_power_control( uint8_t ctl); diff --git a/Online/IPMI/src/NewLib/ipmi_constants.h b/Online/IPMI/src/NewLib/ipmi_constants.h index 4684a24d2d9c1c67e9e1677e27f569094c63f1ee..c0260c6e0e91e4dac4110b3f9474eb1a34cd29a2 100644 --- a/Online/IPMI/src/NewLib/ipmi_constants.h +++ b/Online/IPMI/src/NewLib/ipmi_constants.h @@ -143,4 +143,16 @@ #define IPMI_CRYPT_XRC4_40 0x03 #define SOL_ESCAPE_CHARACTER_DEFAULT '~' +/*typedef*/ enum +{ + SessSup_PingFail =1, + SessSup_auth_capabilities_cmd, + SessSup_BadUserName, + SessSup_NoSlot, + SessSup_NoSlotUser, + SessSup_ActFail, + SessSup_PrivFail, + SessSup_NEXNode, +}; + #endif /*IPMI_CONSTANTS_H*/ diff --git a/Online/IPMI/src/NewLib/ipmi_intf.cpp b/Online/IPMI/src/NewLib/ipmi_intf.cpp index ac0aeb94c2a31e31eb24278047d5a388cc4236a5..8fcc7515687a67314f2e5a5241a6eec0ddcfa09e 100644 --- a/Online/IPMI/src/NewLib/ipmi_intf.cpp +++ b/Online/IPMI/src/NewLib/ipmi_intf.cpp @@ -65,6 +65,8 @@ #include "ipmi_session.h" //#include <ipmitool/ipmi.h> #include "ipmi_sdr.h" +#include "lan.h" +#include "LANPlus.h" //#include <ipmitool/log.h> #define IPMI_DEFAULT_PAYLOAD_SIZE 25 @@ -173,24 +175,6 @@ struct ipmi_intf * ipmi_intf_table[] = { -ipmi_intf::ipmi_intf() -{ - target_addr= IPMI_BMC_SLAVE_ADDR; - chassis = 0; - session = 0; - helper = new ipmi_helper; - oem = 0; -} -ipmi_intf::~ipmi_intf() -{ -// ipmi_close_session_cmd(this); - this->abort = 1; - ipmi_lan_close(this); - if (helper !=0) {delete helper;helper = 0;}; - if (oem !=0) {/*delete oem;*/oem = 0;}; - if (auth!=0) { /*delete auth;*/auth=0;}; - if (session!=0) {delete session;session=0;}; -} /* ipmi_intf_load - Load an interface from the interface table above * If no interface name is given return first entry @@ -201,7 +185,7 @@ ipmi_intf::~ipmi_intf() * returns NULL on error */ -ipmi_intf * ipmi_intf::ipmi_intf_load(char * ) +template <typename T> ipmi_intf<T> * ipmi_intf<T>::ipmi_intf_load(char * ) { // ipmi_intf ** intf; // ipmi_intf * i; @@ -236,7 +220,7 @@ ipmi_intf * ipmi_intf::ipmi_intf_load(char * ) return this; } -void ipmi_intf::ipmi_intf_session_set_hostname( char * hostname) +template <typename T> void ipmi_intf<T>::ipmi_intf_session_set_hostname( char * hostname) { if (session == NULL || hostname == NULL) { return; @@ -248,7 +232,7 @@ void ipmi_intf::ipmi_intf_session_set_hostname( char * hostname) session->hostname = strdup(hostname); } -void ipmi_intf::ipmi_intf_session_set_username( char * username) +template <typename T> void ipmi_intf<T>::ipmi_intf_session_set_username( char * username) { if (session == NULL) return; @@ -260,8 +244,12 @@ void ipmi_intf::ipmi_intf_session_set_username( char * username) memcpy(session->username, username, __min(strlen(username), 16)); } +template <typename T> struct ipmi_rs *ipmi_intf<T>::sendrecv(struct ipmi_rq * req) +{ + return Lan->ipmi_send_cmd(req,&rs); +} -void ipmi_intf::ipmi_intf_session_set_password( char * password) +template <typename T> void ipmi_intf<T>::ipmi_intf_session_set_password( char * password) { if (session == NULL) return; @@ -278,7 +266,7 @@ void ipmi_intf::ipmi_intf_session_set_password( char * password) __min(strlen(password), IPMI_AUTHCODE_BUFFER_SIZE)); } -void ipmi_intf::ipmi_intf_session_set_privlvl( uint8_t level) +template <typename T> void ipmi_intf<T>::ipmi_intf_session_set_privlvl( uint8_t level) { if (session == NULL) return; @@ -286,15 +274,14 @@ void ipmi_intf::ipmi_intf_session_set_privlvl( uint8_t level) session->privlvl = level; } -void ipmi_intf::ipmi_intf_session_set_lookupbit( uint8_t lookupbit) +template <typename T> void ipmi_intf<T>::ipmi_intf_session_set_lookupbit( uint8_t lookupbit) { if (session == NULL) return; - - session->v2_data.lookupbit = lookupbit; + session->lookupbit = lookupbit; } -void ipmi_intf::ipmi_intf_session_set_cipher_suite_id( uint8_t cipher_suite_id) +template <typename T> void ipmi_intf<T>::ipmi_intf_session_set_cipher_suite_id( uint8_t cipher_suite_id) { if (session == NULL) return; @@ -302,7 +289,7 @@ void ipmi_intf::ipmi_intf_session_set_cipher_suite_id( uint8_t cipher_suite_id) session->cipher_suite_id = cipher_suite_id; } -void ipmi_intf::ipmi_intf_session_set_sol_escape_char( char sol_escape_char) +template <typename T> void ipmi_intf<T>::ipmi_intf_session_set_sol_escape_char( char sol_escape_char) { if (session == NULL) return; @@ -310,7 +297,7 @@ void ipmi_intf::ipmi_intf_session_set_sol_escape_char( char sol_escape_char) session->sol_escape_char = sol_escape_char; } -void ipmi_intf::ipmi_intf_session_set_kgkey( char * kgkey) +template <typename T> void ipmi_intf<T>::ipmi_intf_session_set_kgkey( char * kgkey) { if (session == NULL) return; @@ -324,7 +311,7 @@ void ipmi_intf::ipmi_intf_session_set_kgkey( char * kgkey) __min(strlen(kgkey), IPMI_KG_BUFFER_SIZE)); } -void ipmi_intf::ipmi_intf_session_set_port( int port) +template <typename T> void ipmi_intf<T>::ipmi_intf_session_set_port( int port) { if (session == NULL) return; @@ -332,7 +319,7 @@ void ipmi_intf::ipmi_intf_session_set_port( int port) session->port = port; } -void ipmi_intf::ipmi_intf_session_set_authtype( uint8_t authtype) +template <typename T> void ipmi_intf<T>::ipmi_intf_session_set_authtype( uint8_t authtype) { if (session == NULL) return; @@ -346,7 +333,7 @@ void ipmi_intf::ipmi_intf_session_set_authtype( uint8_t authtype) session->authtype_set = authtype; } -void ipmi_intf::ipmi_intf_session_set_timeout( uint32_t timeout) +template <typename T> void ipmi_intf<T>::ipmi_intf_session_set_timeout( uint32_t timeout) { if (session == NULL) return; @@ -354,7 +341,7 @@ void ipmi_intf::ipmi_intf_session_set_timeout( uint32_t timeout) session->timeout = timeout; } -void ipmi_intf::ipmi_intf_session_set_retry( int retry) +template <typename T> void ipmi_intf<T>::ipmi_intf_session_set_retry( int retry) { if (session == NULL) return; @@ -362,7 +349,7 @@ void ipmi_intf::ipmi_intf_session_set_retry( int retry) session->retry = retry; } -void ipmi_intf::ipmi_intf_session_cleanup() +template <typename T> void ipmi_intf<T>::ipmi_intf_session_cleanup() { if (session == NULL) { return; @@ -375,12 +362,12 @@ void ipmi_intf::ipmi_intf_session_cleanup() session = NULL; } -void ipmi_intf::ipmi_cleanup() +template <typename T> void ipmi_intf<T>::ipmi_cleanup() { // ipmi_sdr_list_empty(this); } #include <errno.h> -int ipmi_intf::ipmi_intf_socket_connect() +template <typename T> int ipmi_intf<T>::ipmi_intf_socket_connect() { struct sockaddr_storage addr; @@ -414,7 +401,7 @@ int ipmi_intf::ipmi_intf_socket_connect() if (int sgai=getaddrinfo(session->hostname, service, &hints, &rp0) != 0) { lPrintf(LOG_ERR, "Address lookup for %s failed, Code %d", session->hostname,sgai); - this->sessionsup_fail = SessSup_NEXNode; + Lan->sessionsup_fail = SessSup_NEXNode; return -1; } @@ -518,7 +505,6 @@ int ipmi_intf::ipmi_intf_socket_connect() addr6->sin6_scope_id = ntohs(tmp6->sin6_addr.s6_addr16[1]); } } - /* OK, now try to connect with the scope id from this interface address */ if (addr6->sin6_scope_id != 0) { if (connect(fd, rp->ai_addr, rp->ai_addrlen) != -1) { @@ -537,7 +523,7 @@ int ipmi_intf::ipmi_intf_socket_connect() if (session->ai_family != AF_UNSPEC) { break; } - close(fd); + ::close(fd); fd = -1; } @@ -547,7 +533,7 @@ int ipmi_intf::ipmi_intf_socket_connect() return ((fd != -1) ? 0 : -1); } -uint16_t ipmi_intf::ipmi_intf_get_max_request_data_size() +template <typename T> uint16_t ipmi_intf<T>::ipmi_intf_get_max_request_data_size() { int16_t size; @@ -603,7 +589,7 @@ uint16_t ipmi_intf::ipmi_intf_get_max_request_data_size() return size; } -uint16_t ipmi_intf::ipmi_intf_get_max_response_data_size() +template <typename T> uint16_t ipmi_intf<T>::ipmi_intf_get_max_response_data_size() { int16_t size; @@ -664,7 +650,7 @@ uint16_t ipmi_intf::ipmi_intf_get_max_response_data_size() return size; } -void ipmi_intf::ipmi_intf_set_max_request_data_size( uint16_t size) +template <typename T> void ipmi_intf<T>::ipmi_intf_set_max_request_data_size( uint16_t size) { if (size < IPMI_DEFAULT_PAYLOAD_SIZE) { lPrintf(LOG_ERR, "Request size is too small (%d), leave default size", @@ -675,7 +661,7 @@ void ipmi_intf::ipmi_intf_set_max_request_data_size( uint16_t size) max_request_data_size = size; } -void ipmi_intf::ipmi_intf_set_max_response_data_size( uint16_t size) +template <typename T> void ipmi_intf<T>::ipmi_intf_set_max_response_data_size( uint16_t size) { if (size < IPMI_DEFAULT_PAYLOAD_SIZE - 1) { lPrintf(LOG_ERR, "Response size is too small (%d), leave default size", @@ -685,3 +671,5 @@ void ipmi_intf::ipmi_intf_set_max_response_data_size( uint16_t size) max_response_data_size = size; } +template class ipmi_intf<lan>; +template class ipmi_intf<LANPlus>; diff --git a/Online/IPMI/src/NewLib/ipmi_intf.h b/Online/IPMI/src/NewLib/ipmi_intf.h index 3a045ab7652fbbd65d665c53bd6ce327305f02c4..b083fcb629e388474c4decea805ee006e895cd23 100644 --- a/Online/IPMI/src/NewLib/ipmi_intf.h +++ b/Online/IPMI/src/NewLib/ipmi_intf.h @@ -58,6 +58,7 @@ #include "config.h" #endif #include "ipmi.h" +#include "helper.h" //#if defined(IPMI_INTF_LAN) || defined (IPMI_INTF_LANPLUS) //#include <sys/types.h> //#include <sys/socket.h> @@ -72,7 +73,7 @@ //#include <ipmitool/ipmi.h> //#include <ipmitool/ipmi_sdr.h> //#include <ipmitool/log.h> - +//#include "LANBase.h" enum LANPLUS_SESSION_STATE { LANPLUS_STATE_PRESESSION = 0, LANPLUS_STATE_OPEN_SESSION_SENT, @@ -83,8 +84,7 @@ enum LANPLUS_SESSION_STATE { LANPLUS_STATE_ACTIVE, LANPLUS_STATE_CLOSE_SENT, }; -#include "lan.h" - +//#include "lan.h" #define IPMI_AUTHCODE_BUFFER_SIZE 20 #define IPMI_SIK_BUFFER_SIZE 20 #define IPMI_KG_BUFFER_SIZE 21 /* key plus null byte */ @@ -98,6 +98,7 @@ enum LANPLUS_SESSION_STATE { #define IPMI_DEFAULT_PAYLOAD_SIZE 25 +#include "ipmi_session.h" //#ifdef IPMI_INTF_OPEN //extern ipmi_intf ipmi_open_intf; @@ -133,11 +134,13 @@ enum LANPLUS_SESSION_STATE { * * no meaningful return code */ -class ipmi_session; -class lan; -class ipmi_intf; -class ipmi_chassis; -class ipmi_helper; + +//template <> class ipmi_session; +//class lan; +//class ipmi_intf; +template <class G> class ipmi_chassis; +//class ipmi_helper; +//class ipmi_helper<T>; //class sighand //{ // public: @@ -148,43 +151,56 @@ class ipmi_helper; // } // void sigh(int); //}; -class ipmi_cmd -{ - public: - int (*func)(ipmi_intf * intf, int argc, char ** argv); - const char * name; - const char * desc; +struct ipmi_session_params { + char * hostname; + uint8_t username[17]; + uint8_t authcode_set[IPMI_AUTHCODE_BUFFER_SIZE + 1]; + uint8_t authtype_set; + uint8_t privlvl; + uint8_t cipher_suite_id; + char sol_escape_char; + int password; + int port; + int retry; + uint32_t timeout; + uint8_t kg[IPMI_KG_BUFFER_SIZE]; /* BMC key */ + uint8_t lookupbit; }; -struct ipmi_oem_handle; -class ipmi_intf: public lan +//struct ipmi_oem_handle; +template <class T> class ipmi_oem_handle; +template <class T> class ipmi_session; +template <class T> class ipmi_intf { public: #include "newnew.h" + class ipmi_cmd; + T *Lan; + struct ipmi_session_params ssn_params; char name[16]; char desc[128]; - char *devfile; - int fd; - int opened; - int abort; - int noanswer; - int picmg_avail; - IPMI_OEM manufacturer_id; - ipmi_chassis *chassis; - ipmi_session *session; - ipmi_oem_handle *oem; - ipmi_helper *helper; - ipmi_cmd * cmdlist; - uint8_t target_ipmb_addr; - uint32_t my_addr; - uint32_t target_addr; - uint8_t target_lun; - uint8_t target_channel; - uint32_t transit_addr; - uint8_t transit_channel; - uint16_t max_request_data_size; - uint16_t max_response_data_size; - - uint8_t devnum; + char *devfile=0; + int fd=0; + int opened=0; + int abort=0; + int noanswer=0; + int picmg_avail=0; + IPMI_OEM manufacturer_id=IPMI_OEM_UNKNOWN; + ipmi_chassis<T> *chassis; + ipmi_session<T> *session; + ipmi_oem_handle<T> *oem=0; + ipmi_helper <T> *helper=0; + ipmi_cmd * cmdlist=0; + uint8_t target_ipmb_addr=0; + uint32_t my_addr=0; + uint32_t target_addr=0; + uint8_t target_lun=0; + uint8_t target_channel=0; + uint32_t transit_addr=0; + uint8_t transit_channel=0; + uint16_t max_request_data_size=0; + uint16_t max_response_data_size=0; + + uint8_t devnum = 0; // void ipmi_intf_print(ipmi_intf_support * intflist); @@ -233,21 +249,46 @@ class ipmi_intf: public lan uint16_t ipmi_intf_get_max_response_data_size(); void ipmi_intf_set_max_request_data_size(uint16_t size); - - void ipmi_intf_set_max_response_data_size(uint16_t size); - int setup(){return ipmi_lan_setup(this);}; - int open(){return ipmi_lan_open(this);}; - void ipmi_close(){return ipmi_lan_close(this);}; + void ipmi_intf_set_max_response_data_size( uint16_t size); + void ipmi_intf_set_max_authx_response_data_size(uint16_t size); +// int setup(){return ipmi_lan_setup(this);}; + int ipmi_open(){return Lan->ipmi_open();}; + void ipmi_close(){Lan->ipmi_close();}; + int get_session_setup_code(){return Lan->get_session_setup_code();}; struct ipmi_rs rs; - struct ipmi_rs *sendrecv(struct ipmi_rq * req){return ipmi_lan_send_cmd(this,req,&rs);}; - int sendrsp(struct ipmi_rs *rsp){return ipmi_lan_send_rsp(this,rsp);}; - struct ipmi_rs *recv_sol(){return ipmi_lan_recv_sol(this,&rs);}; - struct ipmi_rs *send_sol(struct ipmi_v2_payload * payload){return ipmi_lan_send_sol(this,payload,&rs);}; - int keepalive(){return ipmi_lan_keepalive(this);}; - void set_max_request_data_size(uint16_t size){return ipmi_lan_set_max_rq_data_size(this,size);}; - void set_max_response_data_size(uint16_t size){return ipmi_lan_set_max_rp_data_size(this,size);}; - ipmi_intf(); - ~ipmi_intf(); + struct ipmi_rs *sendrecv(struct ipmi_rq * req); +// int sendrsp(struct ipmi_rs *rsp){return ipmi_lan_send_rsp(this,rsp);}; +// struct ipmi_rs *recv_sol(){return ipmi_lan_recv_sol(this,&rs);}; +// struct ipmi_rs *send_sol(struct ipmi_v2_payload * payload){return ipmi_lan_send_sol(this,payload,&rs);}; +// int keepalive(){return ipmi_lan_keepalive(this);}; +// void set_max_request_data_size(uint16_t size){return ipmi_lan_set_max_rq_data_size(this,size);}; +// void set_max_response_data_size(uint16_t size){return ipmi_lan_set_max_rp_data_size(this,size);}; + ipmi_intf() + { + target_addr= IPMI_BMC_SLAVE_ADDR; + Lan = new T(this); + chassis = 0; + session = 0; + helper = new ipmi_helper<T>(); + oem = 0; + } + ~ipmi_intf() + { + // ipmi_close_session_cmd(this); + this->abort = 1; + Lan->ipmi_close(); + if (helper !=0) {delete helper;helper = 0;}; + if (oem !=0) {/*delete oem;*/oem = 0;}; +// if (auth!=0) { /*delete auth;*/auth=0;}; + if (session!=0) {delete session;session=0;}; + } }; +template <typename T> class ipmi_cmd +{ + public: + int (*func)(ipmi_intf<T> * intf, int argc, char ** argv); + const char * name; + const char * desc; +}; #endif /* ONLINE_IPMI_SRC_NEWLIB_IPMI_INTF_H_ */ diff --git a/Online/IPMI/src/NewLib/ipmi_oem.cpp b/Online/IPMI/src/NewLib/ipmi_oem.cpp index 53bb0749d9a1922eb1b8702bc438934801acfd95..6b7dafa9405c66d55c3e3b90d4fe4444023cbcad 100644 --- a/Online/IPMI/src/NewLib/ipmi_oem.cpp +++ b/Online/IPMI/src/NewLib/ipmi_oem.cpp @@ -56,14 +56,14 @@ #include "ipmi_sel.h" #include "ipmi_oem.h" -int ipmi_oem_supermicro(struct ipmi_intf * intf); +template <class T> int ipmi_oem_supermicro( ipmi_intf<T> * intf); //int ipmi_oem_ibm(struct ipmi_intf * intf); -struct ipmi_oem_handle ipmi_oem_list[] = { +template <class T> ipmi_oem_handle<T> ipmi_oem_list[] = { { "supermicro", "Supermicro IPMIv1.5 BMC with OEM LAN authentication support", - ipmi_oem_supermicro + ipmi_oem_supermicro<T> }, { "intelwv2", @@ -99,8 +99,7 @@ struct ipmi_oem_handle ipmi_oem_list[] = { }; /* Supermicro IPMIv2 BMCs use OEM authtype */ - int -ipmi_oem_supermicro( ipmi_intf * intf) +template <class T> int ipmi_oem_supermicro( ipmi_intf<T> * intf) { intf->ipmi_intf_session_set_authtype( IPMI_SESSION_AUTHTYPE_OEM); return 0; @@ -118,11 +117,11 @@ ipmi_oem_supermicro( ipmi_intf * intf) /* ipmi_oem_print - print list of OEM handles */ -void ipmi_oem_print(void) +template <class T> void ipmi_oem<T>::ipmi_oem_print(void) { - struct ipmi_oem_handle * oem; + ipmi_oem_handle<T> * oem; lPrintf(LOG_NOTICE, "\nOEM Support:"); - for (oem=ipmi_oem_list; oem->name != NULL && oem->desc != NULL; oem++) { + for (oem=ipmi_oem_list<T>; oem->name != NULL && oem->desc != NULL; oem++) { lPrintf(LOG_NOTICE, "\t%-12s %s", oem->name, oem->desc); } lPrintf(LOG_NOTICE, ""); @@ -136,9 +135,9 @@ void ipmi_oem_print(void) * returns 0 on success * returns -1 on error */ -int ipmi_oem_setup( ipmi_intf * intf, char * oemtype) +template <class T> int ipmi_oem<T>::ipmi_oem_setup( char * oemtype) { - struct ipmi_oem_handle * oem; + ipmi_oem_handle<T> * oem; int rc = 0; if (oemtype == NULL || @@ -148,7 +147,7 @@ int ipmi_oem_setup( ipmi_intf * intf, char * oemtype) return -1; } - for (oem=ipmi_oem_list; oem->name != NULL; oem++) { + for (oem=ipmi_oem_list<T>; oem->name != NULL; oem++) { if (strncmp(oemtype, oem->name, strlen(oem->name)) == 0) break; } @@ -158,7 +157,6 @@ int ipmi_oem_setup( ipmi_intf * intf, char * oemtype) /* save pointer for later use */ intf->oem = oem; - /* run optional setup function if it is defined */ if (oem->setup != NULL) { lPrintf(LOG_DEBUG, "Running OEM setup for \"%s\"", oem->desc); @@ -176,8 +174,7 @@ int ipmi_oem_setup( ipmi_intf * intf, char * oemtype) * returns 1 if requested ipmi handle is active * returns 0 otherwise */ -int -ipmi_oem_active( ipmi_intf * intf, const char * oemtype) +template <class T> int ipmi_oem<T>::ipmi_oem_active(const char * oemtype) { if (intf->oem == NULL) return 0; @@ -187,3 +184,9 @@ ipmi_oem_active( ipmi_intf * intf, const char * oemtype) return 0; } +template class ipmi_oem<LANPlus>; +template class ipmi_oem<lan>; +//class lan; +//class LANPlus; +//template <class T=lan> int ipmi_oem_active( ipmi_intf<lan> * intf, const char * oemtype); +//template <class T=LANPlus> int ipmi_oem_active( ipmi_intf<T> * intf, const char * oemtype); diff --git a/Online/IPMI/src/NewLib/ipmi_oem.h b/Online/IPMI/src/NewLib/ipmi_oem.h index 2f6607f3cbf808ebc61a4820584ec71fd45b0855..86611bf52e85981c24bed4b66c784a86652228bd 100644 --- a/Online/IPMI/src/NewLib/ipmi_oem.h +++ b/Online/IPMI/src/NewLib/ipmi_oem.h @@ -43,17 +43,33 @@ #define IPMI_OEM_H //#include "ipmi.h" - +template <class G> class ipmi_intf; +class LANPlus; +class lan; /* oem handler, see lib/ipmi_oem.c */ -class ipmi_intf; -struct ipmi_oem_handle { - const char * name; - const char * desc; - int (*setup)(ipmi_intf * intf); +template <class T> class ipmi_oem_handle { + public: + const char * name; + const char * desc; + int (*setup)(ipmi_intf<T> * intf); }; -void ipmi_oem_print(void); -int ipmi_oem_setup( ipmi_intf * intf, char * oemtype); -int ipmi_oem_active( ipmi_intf * intf, const char * oemtype); +template <class T> class ipmi_oem +{ + public: + ipmi_intf<T> *intf; + ipmi_oem(ipmi_intf<T> *i) + { + intf = i; + } + void ipmi_oem_print(void); + int ipmi_oem_setup( char * oemtype); + int ipmi_oem_active( const char * oemtype); +}; +//template <class T> void ipmi_oem_print(void); +//template <class T> int ipmi_oem_setup( ipmi_intf<T> * intf, char * oemtype); +//template <class T> int ipmi_oem_active( ipmi_intf<T> * intf, const char * oemtype); +// +// #endif /*IPMI_OEM_H*/ diff --git a/Online/IPMI/src/NewLib/ipmi_sensor.c1 b/Online/IPMI/src/NewLib/ipmi_sensor.c1 deleted file mode 100644 index 395daf94bd9660738be2dd221a08ed6bc76524ac..0000000000000000000000000000000000000000 --- a/Online/IPMI/src/NewLib/ipmi_sensor.c1 +++ /dev/null @@ -1,991 +0,0 @@ -//========================================================================== -// LHCb Online software suite -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see OnlineSys/LICENSE. -// -// Author : B.Jost -// -//========================================================================== -/* - * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. - * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. - * SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE - * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING - * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL - * SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, - * OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR - * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF - * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, - * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - */ - -#include <string.h> -#include <math.h> - -#include <ipmitool/ipmi.h> -#include <ipmitool/helper.h> -#include <ipmitool/log.h> -#include <ipmitool/ipmi_intf.h> -#include <ipmitool/ipmi_sdr.h> -#include <ipmitool/ipmi_sel.h> -#include <ipmitool/ipmi_sensor.h> - -extern int verbose; -void print_sensor_get_usage(); -void print_sensor_thresh_usage(); - -// Macro's for Reading the current sensor Data. -#define SCANNING_DISABLED 0x40 -#define READING_UNAVAILABLE 0x20 -#define INVALID_THRESHOLD "Invalid Threshold data values. Cannot Set Threshold Data." -// static -int -ipmi_sensor_get_sensor_reading_factors( - struct ipmi_intf * intf, - struct sdr_record_full_sensor * sensor, - uint8_t reading) -{ - struct ipmi_rq req; - struct ipmi_rs * rsp; - uint8_t req_data[2]; - - char id[17]; - - if (intf == NULL || sensor == NULL) - return -1; - - memset(id, 0, sizeof(id)); - memcpy(id, sensor->id_string, 16); - - req_data[0] = sensor->cmn.keys.sensor_num; - req_data[1] = reading; - - memset(&req, 0, sizeof(req)); - req.msg.netfn = IPMI_NETFN_SE; - req.msg.lun = sensor->cmn.keys.lun; - req.msg.cmd = GET_SENSOR_FACTORS; - req.msg.data = req_data; - req.msg.data_len = sizeof(req_data); - - rsp = intf->sendrecv(intf, &req); - - if (rsp == NULL) { - lprintf(LOG_ERR, "Error updating reading factor for sensor %s (#%02x)", - id, sensor->cmn.keys.sensor_num); - return -1; - } else if (rsp->ccode) { - return -1; - } else { - /* Update SDR copy with updated Reading Factors for this reading */ - /* Note: - * The Format of the returned data is exactly as in the SDR definition (Little Endian Format), - * therefore we can use raw copy operation here. - * Note: rsp->data[0] would point to the next valid entry in the sampling table - */ - // BUGBUG: uses 'hardcoded' length information from SDR Definition - memcpy(&sensor->mtol, &rsp->data[1], sizeof(sensor->mtol)); - memcpy(&sensor->bacc, &rsp->data[3], sizeof(sensor->bacc)); - return 0; - } - -} - -static -struct ipmi_rs * -ipmi_sensor_set_sensor_thresholds(struct ipmi_intf *intf, - uint8_t sensor, - uint8_t threshold, uint8_t setting, - uint8_t target, uint8_t lun, uint8_t channel) -{ - struct ipmi_rq req; - static struct sensor_set_thresh_rq set_thresh_rq; - struct ipmi_rs *rsp; - uint8_t bridged_request = 0; - uint32_t save_addr; - uint32_t save_channel; - - memset(&set_thresh_rq, 0, sizeof (set_thresh_rq)); - set_thresh_rq.sensor_num = sensor; - set_thresh_rq.set_mask = threshold; - if (threshold == UPPER_NON_RECOV_SPECIFIED) - set_thresh_rq.upper_non_recov = setting; - else if (threshold == UPPER_CRIT_SPECIFIED) - set_thresh_rq.upper_crit = setting; - else if (threshold == UPPER_NON_CRIT_SPECIFIED) - set_thresh_rq.upper_non_crit = setting; - else if (threshold == LOWER_NON_CRIT_SPECIFIED) - set_thresh_rq.lower_non_crit = setting; - else if (threshold == LOWER_CRIT_SPECIFIED) - set_thresh_rq.lower_crit = setting; - else if (threshold == LOWER_NON_RECOV_SPECIFIED) - set_thresh_rq.lower_non_recov = setting; - else - return NULL; - - if (BRIDGE_TO_SENSOR(intf, target, channel)) { - bridged_request = 1; - save_addr = intf->target_addr; - intf->target_addr = target; - save_channel = intf->target_channel; - intf->target_channel = channel; - } - memset(&req, 0, sizeof (req)); - req.msg.netfn = IPMI_NETFN_SE; - req.msg.lun = lun; - req.msg.cmd = SET_SENSOR_THRESHOLDS; - req.msg.data = (uint8_t *) & set_thresh_rq; - req.msg.data_len = sizeof (set_thresh_rq); - - rsp = intf->sendrecv(intf, &req); - if (bridged_request) { - intf->target_addr = save_addr; - intf->target_channel = save_channel; - } - return rsp; -} - -static int -ipmi_sensor_print_fc_discrete(struct ipmi_intf *intf, - struct sdr_record_common_sensor *sensor, - uint8_t sdr_record_type) -{ - const char *id; - struct sensor_reading *sr; - - sr = ipmi_sdr_read_sensor_value(intf, sensor, sdr_record_type, 3); - - if (sr == NULL) { - return -1; - } - - if (csv_output) { - /* NOT IMPLEMENTED */ - } else { - if (verbose == 0) { - /* output format - * id value units status thresholds.... - */ - printf("%-16s ", sr->s_id); - if (sr->s_reading_valid) { - if (sr->s_has_analog_value) { - /* don't show discrete component */ - printf("| %-10s | %-10s | %-6s", - sr->s_a_str, sr->s_a_units, "ok"); - } else { - printf("| 0x%-8x | %-10s | 0x%02x%02x", - sr->s_reading, "discrete", - sr->s_data2, sr->s_data3); - } - } else { - printf("| %-10s | %-10s | %-6s", - "na", "discrete", "na"); - } - printf("| %-10s| %-10s| %-10s| %-10s| %-10s| %-10s", - "na", "na", "na", "na", "na", "na"); - - printf("\n"); - } else { - printf("Sensor ID : %s (0x%x)\n", - sr->s_id, sensor->keys.sensor_num); - printf(" Entity ID : %d.%d\n", - sensor->entity.id, sensor->entity.instance); - printf(" Sensor Type (Discrete): %s\n", - ipmi_sdr_get_sensor_type_desc(sensor->sensor. - type)); - if( sr->s_reading_valid ) - { - if (sr->s_has_analog_value) { - printf(" Sensor Reading : %s %s\n", sr->s_a_str, sr->s_a_units); - } - ipmi_sdr_print_discrete_state("States Asserted", - sensor->sensor.type, - sensor->event_type, - sr->s_data2, - sr->s_data3); - printf("\n"); - } else { - printf(" Unable to read sensor: Device Not Present\n\n"); - } - } - } - - return (sr->s_reading_valid ? 0 : -1 ); -} - -static void -print_thresh_setting(struct sdr_record_full_sensor *full, - uint8_t thresh_is_avail, uint8_t setting, - const char *field_sep, - const char *analog_fmt, - const char *discrete_fmt, - const char *na_fmt) -{ - printf("%s", field_sep); - if (!thresh_is_avail) { - printf(na_fmt, "na"); - return; - } - if (full && !UNITS_ARE_DISCRETE(&full->cmn)) { - printf(analog_fmt, sdr_convert_sensor_reading (full, setting)); - } else { - printf(discrete_fmt, setting); - } -} - -static int -ipmi_sensor_print_fc_threshold(struct ipmi_intf *intf, - struct sdr_record_common_sensor *sensor, - uint8_t sdr_record_type) -{ - int thresh_available = 1; - struct ipmi_rs *rsp; - struct sensor_reading *sr; - - sr = ipmi_sdr_read_sensor_value(intf, sensor, sdr_record_type, 3); - - if (sr == NULL) { - return -1; - } - - const char *thresh_status = ipmi_sdr_get_thresh_status(sr, "ns"); - - /* - * Get sensor thresholds - */ - rsp = ipmi_sdr_get_sensor_thresholds(intf, - sensor->keys.sensor_num, sensor->keys.owner_id, - sensor->keys.lun, sensor->keys.channel); - - if ((rsp == NULL) || (rsp->ccode > 0) || (rsp->data_len == 0)) - thresh_available = 0; - - if (csv_output) { - /* NOT IMPLEMENTED */ - } else { - if (verbose == 0) { - /* output format - * id value units status thresholds.... - */ - printf("%-16s ", sr->s_id); - if (sr->s_reading_valid) { - if (sr->s_has_analog_value) - printf("| %-10.3f | %-10s | %-6s", - sr->s_a_val, sr->s_a_units, thresh_status); - else - printf("| 0x%-8x | %-10s | %-6s", - sr->s_reading, sr->s_a_units, thresh_status); - } else { - printf("| %-10s | %-10s | %-6s", - "na", sr->s_a_units, "na"); - } - if (thresh_available && sr->full) { -#define PTS(bit, dataidx) { \ - print_thresh_setting(sr->full, rsp->data[0] & (bit), \ - rsp->data[(dataidx)], "| ", "%-10.3f", "0x-8x", "%-10s"); \ -} - PTS(LOWER_NON_RECOV_SPECIFIED, 3); - PTS(LOWER_CRIT_SPECIFIED, 2); - PTS(LOWER_NON_CRIT_SPECIFIED, 1); - PTS(UPPER_NON_CRIT_SPECIFIED, 4); - PTS(UPPER_CRIT_SPECIFIED, 5); - PTS(UPPER_NON_RECOV_SPECIFIED, 6); -#undef PTS - } else { - printf - ("| %-10s| %-10s| %-10s| %-10s| %-10s| %-10s", - "na", "na", "na", "na", "na", "na"); - } - - printf("\n"); - } else { - printf("Sensor ID : %s (0x%x)\n", - sr->s_id, sensor->keys.sensor_num); - - printf(" Entity ID : %d.%d\n", - sensor->entity.id, sensor->entity.instance); - - printf(" Sensor Type (Threshold) : %s\n", - ipmi_sdr_get_sensor_type_desc(sensor->sensor. - type)); - - printf(" Sensor Reading : "); - if (sr->s_reading_valid) { - if (sr->full) { - uint16_t raw_tol = __TO_TOL(sr->full->mtol); - if (sr->s_has_analog_value) { - double tol = - sdr_convert_sensor_tolerance(sr->full, - raw_tol); - printf("%.*f (+/- %.*f) %s\n", - (sr->s_a_val == (int) - sr->s_a_val) ? 0 : 3, - sr->s_a_val, - (tol == (int) tol) ? 0 : 3, tol, - sr->s_a_units); - } else { - printf("0x%x (+/- 0x%x) %s\n", - sr->s_reading, - raw_tol, - sr->s_a_units); - } - } else { - printf("0x%x %s\n", sr->s_reading, - sr->s_a_units); - } - printf(" Status : %s\n", thresh_status); - - if (thresh_available) { - if (sr->full) { -#define PTS(bit, dataidx, str) { \ -print_thresh_setting(sr->full, rsp->data[0] & (bit), \ - rsp->data[(dataidx)], \ - (str), "%.3f\n", "0x%x\n", "%s\n"); \ -} - - PTS(LOWER_NON_RECOV_SPECIFIED, 3, " Lower Non-Recoverable : "); - PTS(LOWER_CRIT_SPECIFIED, 2, " Lower Critical : "); - PTS(LOWER_NON_CRIT_SPECIFIED, 1, " Lower Non-Critical : "); - PTS(UPPER_NON_CRIT_SPECIFIED, 4, " Upper Non-Critical : "); - PTS(UPPER_CRIT_SPECIFIED, 5, " Upper Critical : "); - PTS(UPPER_NON_RECOV_SPECIFIED, 6, " Upper Non-Recoverable : "); -#undef PTS - - } - ipmi_sdr_print_sensor_hysteresis(sensor, sr->full, - sr->full ? sr->full->threshold.hysteresis.positive : - sr->compact->threshold.hysteresis.positive, - "Positive Hysteresis"); - - ipmi_sdr_print_sensor_hysteresis(sensor, sr->full, - sr->full ? sr->full->threshold.hysteresis.negative : - sr->compact->threshold.hysteresis.negative, - "Negative Hysteresis"); - } else { - printf(" Sensor Threshold Settings not available\n"); - } - } else { - printf(" Unable to read sensor: Device Not Present\n\n"); - } - - ipmi_sdr_print_sensor_event_status(intf, - sensor->keys. - sensor_num, - sensor->sensor.type, - sensor->event_type, - ANALOG_SENSOR, - sensor->keys.owner_id, - sensor->keys.lun, - sensor->keys.channel); - ipmi_sdr_print_sensor_event_enable(intf, - sensor->keys. - sensor_num, - sensor->sensor.type, - sensor->event_type, - ANALOG_SENSOR, - sensor->keys.owner_id, - sensor->keys.lun, - sensor->keys.channel); - - printf("\n"); - } - } - - return (sr->s_reading_valid ? 0 : -1 ); -} - -int -ipmi_sensor_print_fc(struct ipmi_intf *intf, - struct sdr_record_common_sensor *sensor, - uint8_t sdr_record_type) -{ - if (IS_THRESHOLD_SENSOR(sensor)) - return ipmi_sensor_print_fc_threshold(intf, sensor, sdr_record_type); - else - return ipmi_sensor_print_fc_discrete(intf, sensor, sdr_record_type); -} - -static int -ipmi_sensor_list(struct ipmi_intf *intf) -{ - struct sdr_get_rs *header; - struct ipmi_sdr_iterator *itr; - int rc = 0; - - lprintf(LOG_DEBUG, "Querying SDR for sensor list"); - - itr = ipmi_sdr_start(intf, 0); - if (itr == NULL) { - lprintf(LOG_ERR, "Unable to open SDR for reading"); - return -1; - } - - while ((header = ipmi_sdr_get_next_header(intf, itr)) != NULL) { - uint8_t *rec; - - rec = ipmi_sdr_get_record(intf, header, itr); - if (rec == NULL) { - lprintf(LOG_DEBUG, "rec == NULL"); - continue; - } - - switch (header->type) { - case SDR_RECORD_TYPE_FULL_SENSOR: - case SDR_RECORD_TYPE_COMPACT_SENSOR: - ipmi_sensor_print_fc(intf, - (struct - sdr_record_common_sensor *) - rec, - header->type); - break; - } - free(rec); - rec = NULL; - - /* fix for CR6604909: */ - /* mask failure of individual reads in sensor list command */ - /* rc = (r == 0) ? rc : r; */ - } - - ipmi_sdr_end(intf, itr); - - return rc; -} - -static const struct valstr threshold_vals[] = { - {UPPER_NON_RECOV_SPECIFIED, "Upper Non-Recoverable"}, - {UPPER_CRIT_SPECIFIED, "Upper Critical"}, - {UPPER_NON_CRIT_SPECIFIED, "Upper Non-Critical"}, - {LOWER_NON_RECOV_SPECIFIED, "Lower Non-Recoverable"}, - {LOWER_CRIT_SPECIFIED, "Lower Critical"}, - {LOWER_NON_CRIT_SPECIFIED, "Lower Non-Critical"}, - {0x00, NULL}, -}; - -static int -__ipmi_sensor_set_threshold(struct ipmi_intf *intf, - uint8_t num, uint8_t mask, uint8_t setting, - uint8_t target, uint8_t lun, uint8_t channel) -{ - struct ipmi_rs *rsp; - - rsp = ipmi_sensor_set_sensor_thresholds(intf, num, mask, setting, - target, lun, channel); - - if (rsp == NULL) { - lprintf(LOG_ERR, "Error setting threshold"); - return -1; - } - if (rsp->ccode > 0) { - lprintf(LOG_ERR, "Error setting threshold: %s", - val2str(rsp->ccode, completion_code_vals)); - return -1; - } - - return 0; -} - -static uint8_t -__ipmi_sensor_threshold_value_to_raw(struct sdr_record_full_sensor *full, double value) -{ - if (!UNITS_ARE_DISCRETE(&full->cmn)) { /* Has an analog reading */ - /* Has an analog reading and supports mx+b */ - return sdr_convert_sensor_value_to_raw(full, value); - } - else { - /* Does not have an analog reading and/or does not support mx+b */ - if (value > 255) { - return 255; - } - else if (value < 0) { - return 0; - } - else { - return (uint8_t )value; - } - } -} - -static int -ipmi_sensor_set_threshold(struct ipmi_intf *intf, int argc, char **argv) -{ - char *id, *thresh; - uint8_t settingMask = 0; - double setting1 = 0.0, setting2 = 0.0, setting3 = 0.0; - int allUpper = 0, allLower = 0; - int ret = 0; - struct ipmi_rs *rsp; - int i =0; - double val[10] = {0}; - - struct sdr_record_list *sdr; - - if (argc < 3 || strncmp(argv[0], "help", 4) == 0) { - print_sensor_thresh_usage(); - return 0; - } - - id = argv[0]; - thresh = argv[1]; - - if (strncmp(thresh, "upper", 5) == 0) { - if (argc < 5) { - lprintf(LOG_ERR, - "usage: sensor thresh <id> upper <unc> <ucr> <unr>"); - return -1; - } - allUpper = 1; - if (str2double(argv[2], &setting1) != 0) { - lprintf(LOG_ERR, "Given unc '%s' is invalid.", - argv[2]); - return (-1); - } - if (str2double(argv[3], &setting2) != 0) { - lprintf(LOG_ERR, "Given ucr '%s' is invalid.", - argv[3]); - return (-1); - } - if (str2double(argv[4], &setting3) != 0) { - lprintf(LOG_ERR, "Given unr '%s' is invalid.", - argv[4]); - return (-1); - } - } else if (strncmp(thresh, "lower", 5) == 0) { - if (argc < 5) { - lprintf(LOG_ERR, - "usage: sensor thresh <id> lower <lnr> <lcr> <lnc>"); - return -1; - } - allLower = 1; - if (str2double(argv[2], &setting1) != 0) { - lprintf(LOG_ERR, "Given lnc '%s' is invalid.", - argv[2]); - return (-1); - } - if (str2double(argv[3], &setting2) != 0) { - lprintf(LOG_ERR, "Given lcr '%s' is invalid.", - argv[3]); - return (-1); - } - if (str2double(argv[4], &setting3) != 0) { - lprintf(LOG_ERR, "Given lnr '%s' is invalid.", - argv[4]); - return (-1); - } - } else { - if (strncmp(thresh, "unr", 3) == 0) - settingMask = UPPER_NON_RECOV_SPECIFIED; - else if (strncmp(thresh, "ucr", 3) == 0) - settingMask = UPPER_CRIT_SPECIFIED; - else if (strncmp(thresh, "unc", 3) == 0) - settingMask = UPPER_NON_CRIT_SPECIFIED; - else if (strncmp(thresh, "lnc", 3) == 0) - settingMask = LOWER_NON_CRIT_SPECIFIED; - else if (strncmp(thresh, "lcr", 3) == 0) - settingMask = LOWER_CRIT_SPECIFIED; - else if (strncmp(thresh, "lnr", 3) == 0) - settingMask = LOWER_NON_RECOV_SPECIFIED; - else { - lprintf(LOG_ERR, - "Valid threshold '%s' for sensor '%s' not specified!", - thresh, id); - return -1; - } - if (str2double(argv[2], &setting1) != 0) { - lprintf(LOG_ERR, - "Given %s threshold value '%s' is invalid.", - thresh, argv[2]); - return (-1); - } - } - - printf("Locating sensor record '%s'...\n", id); - - /* lookup by sensor name */ - sdr = ipmi_sdr_find_sdr_byid(intf, id); - if (sdr == NULL) { - lprintf(LOG_ERR, "Sensor data record not found!"); - return -1; - } - - if (sdr->type != SDR_RECORD_TYPE_FULL_SENSOR) { - lprintf(LOG_ERR, "Invalid sensor type %02x", sdr->type); - return -1; - } - - if (!IS_THRESHOLD_SENSOR(sdr->record.common)) { - lprintf(LOG_ERR, "Invalid sensor event type %02x", sdr->record.common->event_type); - return -1; - } - - - if (allUpper) { - settingMask = UPPER_NON_CRIT_SPECIFIED; - printf("Setting sensor \"%s\" %s threshold to %.3f\n", - sdr->record.full->id_string, - val2str(settingMask, threshold_vals), setting1); - ret = __ipmi_sensor_set_threshold(intf, - sdr->record.common->keys. - sensor_num, settingMask, - __ipmi_sensor_threshold_value_to_raw(sdr->record.full, setting1), - sdr->record.common->keys.owner_id, - sdr->record.common->keys.lun, - sdr->record.common->keys.channel); - - settingMask = UPPER_CRIT_SPECIFIED; - printf("Setting sensor \"%s\" %s threshold to %.3f\n", - sdr->record.full->id_string, - val2str(settingMask, threshold_vals), setting2); - ret = __ipmi_sensor_set_threshold(intf, - sdr->record.common->keys. - sensor_num, settingMask, - __ipmi_sensor_threshold_value_to_raw(sdr->record.full, setting2), - sdr->record.common->keys.owner_id, - sdr->record.common->keys.lun, - sdr->record.common->keys.channel); - - settingMask = UPPER_NON_RECOV_SPECIFIED; - printf("Setting sensor \"%s\" %s threshold to %.3f\n", - sdr->record.full->id_string, - val2str(settingMask, threshold_vals), setting3); - ret = __ipmi_sensor_set_threshold(intf, - sdr->record.common->keys. - sensor_num, settingMask, - __ipmi_sensor_threshold_value_to_raw(sdr->record.full, setting3), - sdr->record.common->keys.owner_id, - sdr->record.common->keys.lun, - sdr->record.common->keys.channel); - } else if (allLower) { - settingMask = LOWER_NON_RECOV_SPECIFIED; - printf("Setting sensor \"%s\" %s threshold to %.3f\n", - sdr->record.full->id_string, - val2str(settingMask, threshold_vals), setting1); - ret = __ipmi_sensor_set_threshold(intf, - sdr->record.common->keys. - sensor_num, settingMask, - __ipmi_sensor_threshold_value_to_raw(sdr->record.full, setting1), - sdr->record.common->keys.owner_id, - sdr->record.common->keys.lun, - sdr->record.common->keys.channel); - - settingMask = LOWER_CRIT_SPECIFIED; - printf("Setting sensor \"%s\" %s threshold to %.3f\n", - sdr->record.full->id_string, - val2str(settingMask, threshold_vals), setting2); - ret = __ipmi_sensor_set_threshold(intf, - sdr->record.common->keys. - sensor_num, settingMask, - __ipmi_sensor_threshold_value_to_raw(sdr->record.full, setting2), - sdr->record.common->keys.owner_id, - sdr->record.common->keys.lun, - sdr->record.common->keys.channel); - - settingMask = LOWER_NON_CRIT_SPECIFIED; - printf("Setting sensor \"%s\" %s threshold to %.3f\n", - sdr->record.full->id_string, - val2str(settingMask, threshold_vals), setting3); - ret = __ipmi_sensor_set_threshold(intf, - sdr->record.common->keys. - sensor_num, settingMask, - __ipmi_sensor_threshold_value_to_raw(sdr->record.full, setting3), - sdr->record.common->keys.owner_id, - sdr->record.common->keys.lun, - sdr->record.common->keys.channel); - } else { - - /* - * Current implementation doesn't check for the valid setting of upper non critical and other thresholds. - * In the below logic: - * Get all the current reading of the sensor i.e. unc, uc, lc,lnc. - * Validate the values given by the user. - * If the values are not correct, then popup with the Error message and return. - */ - /* - * Get current reading - */ - rsp = ipmi_sdr_get_sensor_reading_ipmb(intf, - sdr->record.common->keys.sensor_num, - sdr->record.common->keys.owner_id, - sdr->record.common->keys.lun,sdr->record.common->keys.channel); - rsp = ipmi_sdr_get_sensor_thresholds(intf, - sdr->record.common->keys.sensor_num, - sdr->record.common->keys.owner_id, - sdr->record.common->keys.lun, - sdr->record.common->keys.channel); - if ((rsp == NULL) || (rsp->ccode > 0)) { - lprintf(LOG_ERR, "Sensor data record not found!"); - return -1; - } - for(i=1;i<=6;i++) { - val[i] = sdr_convert_sensor_reading(sdr->record.full, rsp->data[i]); - if(val[i] < 0) - val[i] = 0; - } - /* Check for the valid Upper non recovarable Value.*/ - if( (settingMask & UPPER_NON_RECOV_SPECIFIED) ) { - - if( (rsp->data[0] & UPPER_NON_RECOV_SPECIFIED) && - (( (rsp->data[0] & UPPER_CRIT_SPECIFIED) && ( setting1 <= val[5])) || - ( (rsp->data[0] & UPPER_NON_CRIT_SPECIFIED) && ( setting1 <= val[4]))) ) - { - lprintf(LOG_ERR, INVALID_THRESHOLD); - return -1; - } - } else if( (settingMask & UPPER_CRIT_SPECIFIED) ) { /* Check for the valid Upper critical Value.*/ - if( (rsp->data[0] & UPPER_CRIT_SPECIFIED) && - (((rsp->data[0] & UPPER_NON_RECOV_SPECIFIED)&& ( setting1 >= val[6])) || - ((rsp->data[0] & UPPER_NON_CRIT_SPECIFIED)&&( setting1 <= val[4]))) ) - { - lprintf(LOG_ERR, INVALID_THRESHOLD); - return -1; - } - } else if( (settingMask & UPPER_NON_CRIT_SPECIFIED) ) { /* Check for the valid Upper non critical Value.*/ - if( (rsp->data[0] & UPPER_NON_CRIT_SPECIFIED) && - (((rsp->data[0] & UPPER_NON_RECOV_SPECIFIED)&&( setting1 >= val[6])) || - ((rsp->data[0] & UPPER_CRIT_SPECIFIED)&&( setting1 >= val[5])) || - ((rsp->data[0] & LOWER_NON_CRIT_SPECIFIED)&&( setting1 <= val[1]))) ) - { - lprintf(LOG_ERR, INVALID_THRESHOLD); - return -1; - } - } else if( (settingMask & LOWER_NON_CRIT_SPECIFIED) ) { /* Check for the valid lower non critical Value.*/ - if( (rsp->data[0] & LOWER_NON_CRIT_SPECIFIED) && - (((rsp->data[0] & LOWER_CRIT_SPECIFIED)&&( setting1 <= val[2])) || - ((rsp->data[0] & LOWER_NON_RECOV_SPECIFIED)&&( setting1 <= val[3]))|| - ((rsp->data[0] & UPPER_NON_CRIT_SPECIFIED)&&( setting1 >= val[4]))) ) - { - lprintf(LOG_ERR, INVALID_THRESHOLD); - return -1; - } - } else if( (settingMask & LOWER_CRIT_SPECIFIED) ) { /* Check for the valid lower critical Value.*/ - if( (rsp->data[0] & LOWER_CRIT_SPECIFIED) && - (((rsp->data[0] & LOWER_NON_CRIT_SPECIFIED)&&( setting1 >= val[1])) || - ((rsp->data[0] & LOWER_NON_RECOV_SPECIFIED)&&( setting1 <= val[3]))) ) - { - lprintf(LOG_ERR, INVALID_THRESHOLD); - return -1; - } - } else if( (settingMask & LOWER_NON_RECOV_SPECIFIED) ) { /* Check for the valid lower non recovarable Value.*/ - if( (rsp->data[0] & LOWER_NON_RECOV_SPECIFIED) && - (((rsp->data[0] & LOWER_NON_CRIT_SPECIFIED)&&( setting1 >= val[1])) || - ((rsp->data[0] & LOWER_CRIT_SPECIFIED)&&( setting1 >= val[2]))) ) - { - lprintf(LOG_ERR, INVALID_THRESHOLD); - return -1; - } - } else { /* None of this Then Return with error messages.*/ - lprintf(LOG_ERR, INVALID_THRESHOLD); - return -1; - } - - - printf("Setting sensor \"%s\" %s threshold to %.3f\n", - sdr->record.full->id_string, - val2str(settingMask, threshold_vals), setting1); - - ret = __ipmi_sensor_set_threshold(intf, - sdr->record.common->keys. - sensor_num, settingMask, - __ipmi_sensor_threshold_value_to_raw(sdr->record.full, setting1), - sdr->record.common->keys.owner_id, - sdr->record.common->keys.lun, - sdr->record.common->keys.channel); - } - - return ret; -} - -static int -ipmi_sensor_get_reading(struct ipmi_intf *intf, int argc, char **argv) -{ - struct sdr_record_list *sdr; - int i, rc=0; - - if (argc < 1 || strncmp(argv[0], "help", 4) == 0) { - lprintf(LOG_NOTICE, "sensor reading <id> ... [id]"); - lprintf(LOG_NOTICE, " id : name of desired sensor"); - return -1; - } - - for (i = 0; i < argc; i++) { - sdr = ipmi_sdr_find_sdr_byid(intf, argv[i]); - if (sdr == NULL) { - lprintf(LOG_ERR, "Sensor \"%s\" not found!", - argv[i]); - rc = -1; - continue; - } - - switch (sdr->type) { - case SDR_RECORD_TYPE_FULL_SENSOR: - case SDR_RECORD_TYPE_COMPACT_SENSOR: - { - struct sensor_reading *sr; - struct sdr_record_common_sensor *sensor = sdr->record.common; - sr = ipmi_sdr_read_sensor_value(intf, sensor, sdr->type, 3); - - if (sr == NULL) { - rc = -1; - continue; - } - - if (!sr->full) - continue; - - if (!sr->s_reading_valid) - continue; - - if (!sr->s_has_analog_value) { - lprintf(LOG_ERR, "Sensor \"%s\" is a discrete sensor!", argv[i]); - continue; - } - if (csv_output) - printf("%s,%s\n", argv[i], sr->s_a_str); - else - printf("%-16s | %s\n", argv[i], sr->s_a_str); - - break; - } - default: - continue; - } - } - - return rc; -} - -static int -ipmi_sensor_get(struct ipmi_intf *intf, int argc, char **argv) -{ - int i, v; - int rc = 0; - struct sdr_record_list *sdr; - - if (argc < 1) { - lprintf(LOG_ERR, "Not enough parameters given."); - print_sensor_get_usage(); - return (-1); - } else if (strcmp(argv[0], "help") == 0) { - print_sensor_get_usage(); - return 0; - } - printf("Locating sensor record...\n"); - /* lookup by sensor name */ - for (i = 0; i < argc; i++) { - sdr = ipmi_sdr_find_sdr_byid(intf, argv[i]); - if (sdr == NULL) { - lprintf(LOG_ERR, "Sensor data record \"%s\" not found!", - argv[i]); - rc = -1; - continue; - } - /* need to set verbose level to 1 */ - v = verbose; - verbose = 1; - if (ipmi_sdr_print_listentry(intf, sdr) < 0) { - rc = (-1); - } - verbose = v; - sdr = NULL; - } - return rc; -} - -int -ipmi_sensor_main(struct ipmi_intf *intf, int argc, char **argv) -{ - int rc = 0; - - if (argc == 0) { - rc = ipmi_sensor_list(intf); - } else if (strncmp(argv[0], "help", 4) == 0) { - lprintf(LOG_NOTICE, "Sensor Commands: list thresh get reading"); - } else if (strncmp(argv[0], "list", 4) == 0) { - rc = ipmi_sensor_list(intf); - } else if (strncmp(argv[0], "thresh", 5) == 0) { - rc = ipmi_sensor_set_threshold(intf, argc - 1, &argv[1]); - } else if (strncmp(argv[0], "get", 3) == 0) { - rc = ipmi_sensor_get(intf, argc - 1, &argv[1]); - } else if (strncmp(argv[0], "reading", 7) == 0) { - rc = ipmi_sensor_get_reading(intf, argc - 1, &argv[1]); - } else { - lprintf(LOG_ERR, "Invalid sensor command: %s", argv[0]); - rc = -1; - } - - return rc; -} - -/* print_sensor_get_usage - print usage for # ipmitool sensor get NAC; - * - * @returns: void - */ -void -print_sensor_get_usage() -{ - lprintf(LOG_NOTICE, "sensor get <id> ... [id]"); - lprintf(LOG_NOTICE, " id : name of desired sensor"); -} - -/* print_sensor_thresh_set_usage - print usage for # ipmitool sensor thresh; - * - * @returns: void - */ -void -print_sensor_thresh_usage() -{ - lprintf(LOG_NOTICE, -"sensor thresh <id> <threshold> <setting>"); - lprintf(LOG_NOTICE, -" id : name of the sensor for which threshold is to be set"); - lprintf(LOG_NOTICE, -" threshold : which threshold to set"); - lprintf(LOG_NOTICE, -" unr = upper non-recoverable"); - lprintf(LOG_NOTICE, -" ucr = upper critical"); - lprintf(LOG_NOTICE, -" unc = upper non-critical"); - lprintf(LOG_NOTICE, -" lnc = lower non-critical"); - lprintf(LOG_NOTICE, -" lcr = lower critical"); - lprintf(LOG_NOTICE, -" lnr = lower non-recoverable"); - lprintf(LOG_NOTICE, -" setting : the value to set the threshold to"); - lprintf(LOG_NOTICE, -""); - lprintf(LOG_NOTICE, -"sensor thresh <id> lower <lnr> <lcr> <lnc>"); - lprintf(LOG_NOTICE, -" Set all lower thresholds at the same time"); - lprintf(LOG_NOTICE, -""); - lprintf(LOG_NOTICE, -"sensor thresh <id> upper <unc> <ucr> <unr>"); - lprintf(LOG_NOTICE, -" Set all upper thresholds at the same time"); - lprintf(LOG_NOTICE, ""); -} diff --git a/Online/IPMI/src/NewLib/ipmi_session.cpp b/Online/IPMI/src/NewLib/ipmi_session.cpp index 259f5d0af9f94a9fb89bcc21fceeceaeb4c558ab..e5e92266a8b9f31c7f6a5acd1ee0d537bea3a5d2 100644 --- a/Online/IPMI/src/NewLib/ipmi_session.cpp +++ b/Online/IPMI/src/NewLib/ipmi_session.cpp @@ -52,7 +52,8 @@ #include <unistd.h> #include <signal.h> #include "log.h" - +#include "lan.h" +#include "LANPlus.h" //#include <ipmitool/ipmi.h> //#include <ipmitool/ipmi_intf.h> //#include <ipmitool/helper.h> @@ -71,7 +72,13 @@ /* * print_session_info_csv */ -void ipmi_session::print_session_info_csv(const struct get_session_info_rsp * session_info, int data_len) +template<typename T> ipmi_session<T>::ipmi_session(ipmi_intf<T> *i) + { + iface = i; + hostname = 0; + }; + +template<typename T> void ipmi_session<T>::print_session_info_csv(const struct get_session_info_rsp * session_info, int data_len) { char buffer[18]; uint16_t console_port_tmp; @@ -154,7 +161,7 @@ void ipmi_session::print_session_info_csv(const struct get_session_info_rsp * s /* * print_session_info_verbose */ -void ipmi_session::print_session_info_verbose(const struct get_session_info_rsp * session_info, int data_len) +template <typename T> void ipmi_session<T>::print_session_info_verbose(const struct get_session_info_rsp * session_info, int data_len) { char buffer[18]; uint16_t console_port_tmp; @@ -236,7 +243,7 @@ void ipmi_session::print_session_info_verbose(const struct get_session_info_rsp } -void ipmi_session::print_session_info(const struct get_session_info_rsp * session_info, +template <typename T> void ipmi_session<T>::print_session_info(const struct get_session_info_rsp * session_info, int data_len) { if (csv_output) @@ -252,7 +259,7 @@ void ipmi_session::print_session_info(const struct get_session_info_rsp * sessi * returns 0 on success * -1 on error */ -int ipmi_session::ipmi_get_session_info(ipmi_intf *intf, Ipmi_Session_Request_Type session_request_type, +template <typename T> int ipmi_session<T>::ipmi_get_session_info( Ipmi_Session_Request_Type session_request_type, uint32_t id_or_handle) { int i, retval = 0; @@ -261,8 +268,8 @@ int ipmi_session::ipmi_get_session_info(ipmi_intf *intf, Ipmi_Session_Request_Ty struct ipmi_rq req; uint8_t rqdata[5]; // max length of the variable length request struct get_session_info_rsp session_info; - - memset(&req, 0, sizeof(req)); + req.zero(); +// memset(&req, 0, sizeof(req)); memset(&session_info, 0, sizeof(session_info)); req.msg.netfn = IPMI_NETFN_APP; // 0x06 req.msg.cmd = IPMI_GET_SESSION_INFO; // 0x3D @@ -297,7 +304,7 @@ int ipmi_session::ipmi_get_session_info(ipmi_intf *intf, Ipmi_Session_Request_Ty break; } - rsp = intf->sendrecv( &req); + rsp = iface->sendrecv( &req); if (rsp == NULL) { lPrintf(LOG_ERR, "Get Session Info command failed"); @@ -313,7 +320,7 @@ int ipmi_session::ipmi_get_session_info(ipmi_intf *intf, Ipmi_Session_Request_Ty if (retval < 0) { if ((session_request_type == IPMI_SESSION_REQUEST_CURRENT) && - (strncmp(intf->name, "lan", 3) != 0)) + (strncmp(iface->name, "lan", 3) != 0)) lPrintf(LOG_ERR, "It is likely that the channel in use " "does not support sessions"); } @@ -330,7 +337,7 @@ int ipmi_session::ipmi_get_session_info(ipmi_intf *intf, Ipmi_Session_Request_Ty do { rqdata[0] = i++; - rsp = intf->sendrecv( &req); + rsp = iface->sendrecv( &req); if (rsp == NULL) { @@ -363,15 +370,13 @@ int ipmi_session::ipmi_get_session_info(ipmi_intf *intf, Ipmi_Session_Request_Ty -void -ipmi_session::Printf_session_usage(void) +template <typename T> void ipmi_session<T>::Printf_session_usage(void) { lPrintf(LOG_NOTICE, "Session Commands: info <active | all | id 0xnnnnnnnn | handle 0xnn>"); } -int -ipmi_session::ipmi_session_main(ipmi_intf * intf, int argc, char ** argv) +template <typename T> int ipmi_session<T>::ipmi_session_main( int argc, char ** argv) { int retval = 0; @@ -442,7 +447,7 @@ ipmi_session::ipmi_session_main(ipmi_intf * intf, int argc, char ** argv) if (retval == 0) - retval = ipmi_get_session_info(intf, + retval = ipmi_get_session_info( session_request_type, id_or_handle); } @@ -457,3 +462,5 @@ ipmi_session::ipmi_session_main(ipmi_intf * intf, int argc, char ** argv) return retval; } +template class ipmi_session<LANPlus>; +template class ipmi_session<lan>; diff --git a/Online/IPMI/src/NewLib/ipmi_session.h b/Online/IPMI/src/NewLib/ipmi_session.h index 223c7a09721c5d64047aa4e76ffc7632f402d3ec..fb7bbb15aa4625f5987bc62115ffc7cf97edb99c 100644 --- a/Online/IPMI/src/NewLib/ipmi_session.h +++ b/Online/IPMI/src/NewLib/ipmi_session.h @@ -64,7 +64,7 @@ typedef enum # include "config.h" #endif #include "ipmi.h" - +//#include "ipmi_intf.h" #define IPMI_GET_SESSION_INFO 0x3D /* @@ -150,48 +150,50 @@ struct get_session_info_rsp #ifdef HAVE_PRAGMA_PACK #pragma pack(0) #endif +#define IPMI_AUTHSTATUS_PER_MSG_DISABLED 0x10 +#define IPMI_AUTHSTATUS_PER_USER_DISABLED 0x08 +#define IPMI_AUTHSTATUS_NONNULL_USERS_ENABLED 0x04 +#define IPMI_AUTHSTATUS_NULL_USERS_ENABLED 0x02 +#define IPMI_AUTHSTATUS_ANONYMOUS_USERS_ENABLED 0x01 -class ipmi_intf; - -class ipmi_session +//template <class T> using ityp=ipmi_intf<T>; +template <class G> class ipmi_intf; +template <class T> class ipmi_session { public: #include "newnew.h" - /* - * print_session_info_csv - */ - ipmi_intf *iface; +/* + * print_session_info_csv + */ +// using ityp=ipmi_intf<T>; + ipmi_intf<T> *iface; char *hostname; /* Numeric IP adress or DNS name - see RFC 1034/RFC 1035 */ uint8_t username[17]; uint8_t authcode[IPMI_AUTHCODE_BUFFER_SIZE + 1]; uint8_t challenge[16]; - uint8_t authtype; - uint8_t authtype_set; -#define IPMI_AUTHSTATUS_PER_MSG_DISABLED 0x10 -#define IPMI_AUTHSTATUS_PER_USER_DISABLED 0x08 -#define IPMI_AUTHSTATUS_NONNULL_USERS_ENABLED 0x04 -#define IPMI_AUTHSTATUS_NULL_USERS_ENABLED 0x02 -#define IPMI_AUTHSTATUS_ANONYMOUS_USERS_ENABLED 0x01 - uint8_t authstatus; - uint8_t authextra; - uint8_t privlvl; - uint8_t cipher_suite_id; - char sol_escape_char; - int password; - int port; - int active; - int retry; - - uint32_t session_id; - uint32_t in_seq; - uint32_t out_seq; - uint32_t timeout; + uint8_t authtype=0; + uint8_t authtype_set=0; + uint8_t authstatus=0; + uint8_t authextra=0; + uint8_t privlvl=0; + uint8_t cipher_suite_id=0; + char sol_escape_char=0; + int password=0; + int port=0; + int active=0; + int retry=0; + int lookupbit; + uint32_t session_id=0; + uint32_t in_seq=0; + uint32_t out_seq=0; + uint32_t timeout=0; + uint8_t kg[IPMI_KG_BUFFER_SIZE]; /* BMC key */ struct sockaddr_storage addr; - socklen_t addrlen; - int ai_family; /* Protocol family for socket. */ + socklen_t addrlen=0; + int ai_family=0; /* Protocol family for socket. */ /* * This struct holds state data specific to IPMI v2 / RMCP+ sessions @@ -207,7 +209,6 @@ class ipmi_session uint8_t integrity_alg; uint8_t crypt_alg; uint8_t max_priv_level; - uint8_t lookupbit; uint32_t console_id; uint32_t bmc_id; @@ -225,13 +226,15 @@ class ipmi_session uint8_t requested_role; /* As sent in the RAKP 1 message */ uint8_t rakp2_return_code; - uint8_t sik[IPMI_SIK_BUFFER_SIZE]; /* Session integrity key */ - uint8_t kg[IPMI_KG_BUFFER_SIZE]; /* BMC key */ - uint8_t k1[20]; /* Used for Integrity checking? */ - uint8_t k2[20]; /* First 16 bytes used for AES */ + uint8_t sik[IPMI_SIK_BUFFER_SIZE]; /* Session integrity key */ + uint8_t sik_len; /* Session Integrity key length */ + uint8_t kg[IPMI_KG_BUFFER_SIZE]; /* BMC key */ + uint8_t k1[IPMI_MAX_MD_SIZE]; /* Used for Integrity checking? */ + uint8_t k1_len; /* K1 key length */ + uint8_t k2[IPMI_MAX_MD_SIZE]; /* First 16 bytes used for AES */ + uint8_t k2_len; /* K2 key length */ } v2_data; - /* * This data is specific to the Serial Over Lan session */ @@ -263,17 +266,17 @@ class ipmi_session * returns 0 on success * -1 on error */ - int ipmi_get_session_info( ipmi_intf * intf, + int ipmi_get_session_info( Ipmi_Session_Request_Type session_request_type, uint32_t id_or_handle); void Printf_session_usage(void); - int ipmi_session_main( ipmi_intf * intf, int argc, char ** argv); - ipmi_session(ipmi_intf *i) - { - iface = i; - hostname = 0; - }; + int ipmi_session_main( int argc, char ** argv); + ipmi_session(ipmi_intf<T> *i); +// { +// iface = i; +// hostname = 0; +// }; }; #endif /* ONLINE_IPMI_SRC_NEWLIB_IPMI_SESSION_H_ */ diff --git a/Online/IPMI/src/NewLib/ipmi_strings.cpp b/Online/IPMI/src/NewLib/ipmi_strings.cpp index 8c26e75b37e225119e8cd4a821f082d19887ca2f..720572743243fec0ecd13920621a7b9803956620 100644 --- a/Online/IPMI/src/NewLib/ipmi_strings.cpp +++ b/Online/IPMI/src/NewLib/ipmi_strings.cpp @@ -81,6 +81,13 @@ const struct valstr ipmi_oem_info[] = { { IPMI_OEM_BROADCOM, "Broadcom Corporation" }, { 0xffff , NULL }, }; +const struct valstr ipmi_user_enable_status_vals[] = { + { 0x00, "unknown" }, + { 0x40, "enabled" }, + { 0x80, "disabled" }, + { 0xC0, "reserved" }, + { 0xFF, NULL }, +}; const struct oemvalstr ipmi_oem_product_info[] = { /* Keep OEM grouped together */ diff --git a/Online/IPMI/src/NewLib/ipmi_strings.h b/Online/IPMI/src/NewLib/ipmi_strings.h index 3877e369de9de2d12c97485000462fa1b604c5e8..5093947aa3631215283e40c23035433a06328cfd 100644 --- a/Online/IPMI/src/NewLib/ipmi_strings.h +++ b/Online/IPMI/src/NewLib/ipmi_strings.h @@ -63,6 +63,7 @@ extern const struct valstr ipmi_auth_algorithms[]; extern const struct valstr ipmi_integrity_algorithms[]; extern const struct valstr ipmi_encryption_algorithms[]; extern const struct valstr ipmi_oem_info[]; +extern const struct valstr ipmi_user_enable_status_vals[]; extern const struct valstr picmg_frucontrol_vals[]; extern const struct valstr picmg_clk_family_vals[]; diff --git a/Online/IPMI/src/NewLib/ipmi_user.cpp b/Online/IPMI/src/NewLib/ipmi_user.cpp new file mode 100755 index 0000000000000000000000000000000000000000..bdf566bb079a5c5235816bb770432212dfde1eb8 --- /dev/null +++ b/Online/IPMI/src/NewLib/ipmi_user.cpp @@ -0,0 +1,799 @@ +/* + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. + * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. + * SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE + * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING + * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL + * SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, + * OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR + * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF + * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, + * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + */ +#define _BSD_SOURCE || \ + (_XOPEN_SOURCE >= 500 || \ + _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) && \ + !(_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) + +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <sys/types.h> +#include <sys/select.h> +#include <sys/time.h> +#include <signal.h> +#include <unistd.h> + +#include "log.h" +//#include "ipmi.h" +#include "ipmi_intf.h" +#include "ipmi_user.h" +#include "ipmi_constants.h" +#include "ipmi_strings.h" +#include "helper.h" +#include "bswap.h" +#include "lan.h" +#include "LANPlus.h" +extern int verbose; +extern int csv_output; + +/* _ipmi_get_user_access - Get User Access for given channel. Results are stored + * into passed struct. + * + * @intf - IPMI interface + * @user_access_rsp - ptr to user_access_t with UID and Channel set + * + * returns - negative number means error, positive is a ccode + */ +template<class T> ipmi_user<T>::ipmi_user(ipmi_intf<T> *i) +{ + h = new ipmi_helper<T>(); + intf = i; +} + +template<class T> int ipmi_user<T>::get_user_access( struct user_access_t *user_access_rsp) +{ + struct ipmi_rq req;// = { 0 }; + struct ipmi_rs *rsp; + uint8_t data[2]; + if (user_access_rsp == NULL) + { + return (-3); + } + data[0] = user_access_rsp->channel & 0x0F; + data[1] = user_access_rsp->user_id & 0x3F; + req.msg.netfn = IPMI_NETFN_APP; + req.msg.cmd = IPMI_GET_USER_ACCESS; + req.msg.data = data; + req.msg.data_len = 2; + rsp = intf->sendrecv( &req); + if (rsp == NULL) + { + return (-1); + } + else if (rsp->ccode != 0) + { + return rsp->ccode; + } + else if (rsp->data_len != 4) + { + return (-2); + } + user_access_rsp->max_user_ids = rsp->data[0] & 0x3F; + user_access_rsp->enable_status = rsp->data[1] & 0xC0; + user_access_rsp->enabled_user_ids = rsp->data[1] & 0x3F; + user_access_rsp->fixed_user_ids = rsp->data[2] & 0x3F; + user_access_rsp->callin_callback = rsp->data[3] & 0x40; + user_access_rsp->link_auth = rsp->data[3] & 0x20; + user_access_rsp->ipmi_messaging = rsp->data[3] & 0x10; + user_access_rsp->privilege_limit = rsp->data[3] & 0x0F; + return rsp->ccode; +} + +/* _ipmi_get_user_name - Fetch User Name for given User ID. User Name is stored + * into passed structure. + * + * @intf - ipmi interface + * @user_name - user_name_t struct with UID set + * + * returns - negative number means error, positive is a ccode + */ +template<class T> int ipmi_user<T>::get_user_name( struct user_name_t *user_name_ptr) +{ + struct ipmi_rq req ; + struct ipmi_rs *rsp; + uint8_t data[1]; + if (user_name_ptr == NULL) + { + return (-3); + } + data[0] = user_name_ptr->user_id & 0x3F; + req.msg.netfn = IPMI_NETFN_APP; + req.msg.cmd = IPMI_GET_USER_NAME; + req.msg.data = data; + req.msg.data_len = 1; + rsp = intf->sendrecv( &req); + if (rsp == NULL) + { + return (-1); + } + else if (rsp->ccode > 0) + { + return rsp->ccode; + } + else if (rsp->data_len != 16) + { + return (-2); + } + memset(user_name_ptr->user_name, '\0', 17); + memcpy(user_name_ptr->user_name, rsp->data, 16); + return rsp->ccode; +} + +/* _ipmi_set_user_access - Set User Access for given channel. + * + * @intf - IPMI interface + * @user_access_req - ptr to user_access_t with desired User Access. + * @change_priv_limit_only - change User's privilege limit only + * + * returns - negative number means error, positive is a ccode + */ +template<class T> int ipmi_user<T>::set_user_access( struct user_access_t *user_access_req, + uint8_t change_priv_limit_only) +{ + uint8_t data[4]; + struct ipmi_rq req; + struct ipmi_rs *rsp; + if (user_access_req == NULL) + { + return (-3); + } + data[0] = change_priv_limit_only ? 0x00 : 0x80; + if (user_access_req->callin_callback) + { + data[0] |= 0x40; + } + if (user_access_req->link_auth) + { + data[0] |= 0x20; + } + if (user_access_req->ipmi_messaging) + { + data[0] |= 0x10; + } + data[0] |= (user_access_req->channel & 0x0F); + data[1] = user_access_req->user_id & 0x3F; + data[2] = user_access_req->privilege_limit & 0x0F; + data[3] = user_access_req->session_limit & 0x0F; + req.msg.netfn = IPMI_NETFN_APP; + req.msg.cmd = IPMI_SET_USER_ACCESS; + req.msg.data = data; + req.msg.data_len = 4; + rsp = intf->sendrecv( &req); + if (rsp == NULL) + { + return (-1); + } + else + { + return rsp->ccode; + } +} + +/* _ipmi_set_user_password - Set User Password command. + * + * @intf - IPMI interface + * @user_id - IPMI User ID + * @operation - which operation to perform(en/disable user, set/test password) + * @password - User Password + * @is_twenty_byte - 0 = store as 16byte, otherwise store as 20byte password + * + * returns - negative number means error, positive is a ccode + */ +template<class T> int ipmi_user<T>::set_user_password( uint8_t user_id, uint8_t operation, + const char *password, uint8_t is_twenty_byte) +{ + struct ipmi_rq req; + struct ipmi_rs *rsp; + uint8_t *data; + uint8_t data_len = (is_twenty_byte) ? 22 : 18; + data = (uint8_t*)malloc(sizeof(uint8_t) * data_len); + if (data == NULL) + { + return (-4); + } + memset(data, 0, data_len); + data[0] = (is_twenty_byte) ? 0x80 : 0x00; + data[0] |= (0x0F & user_id); + data[1] = 0x03 & operation; + if (password != NULL) + { + int copy_len = strlen(password); + if (copy_len > (data_len - 2)) + { + copy_len = data_len - 2; + } + else if (copy_len < 1) + { + copy_len = 0; + } + strncpy((char *) (data + 2), password, copy_len); + } + + req.msg.netfn = IPMI_NETFN_APP; + req.msg.cmd = IPMI_SET_USER_PASSWORD; + req.msg.data = data; + req.msg.data_len = data_len; + rsp = intf->sendrecv( &req); + free(data); + data = NULL; + if (rsp == NULL) + { + return (-1); + } + return rsp->ccode; +} + +template<class T> void ipmi_user<T>::dump_user_access(const char *user_name, struct user_access_t *user_access) +{ + static int printed_header = 0; + if (!printed_header) + { + printf("ID Name Callin Link Auth IPMI Msg " + "Channel Priv Limit\n"); + printed_header = 1; + } + printf("%-4d%-17s%-8s%-11s%-11s%-s\n", user_access->user_id, user_name, + user_access->callin_callback ? "false" : "true ", user_access->link_auth ? "true " : "false", + user_access->ipmi_messaging ? "true " : "false", h->val2str(user_access->privilege_limit, ipmi_privlvl_vals)); +} + +template<class T> void ipmi_user<T>::dump_user_access_csv(const char *user_name, struct user_access_t *user_access) +{ + printf("%d,%s,%s,%s,%s,%s\n", user_access->user_id, user_name, user_access->callin_callback ? "false" : "true", + user_access->link_auth ? "true" : "false", user_access->ipmi_messaging ? "true" : "false", + h->val2str(user_access->privilege_limit, ipmi_privlvl_vals)); +} + +/* ipmi_print_user_list - List IPMI Users and their ACLs for given channel. + * + * @intf - IPMI interface + * @channel_number - IPMI channel + * + * returns - 0 on success, (-1) on error + */ +template<class T> int ipmi_user<T>::print_user_list(uint8_t channel_number) +{ + struct user_access_t user_access; + struct user_name_t user_name; + int ccode = 0; + uint8_t current_user_id = 1; + do + { + user_access.zero(); + user_access.user_id = current_user_id; + user_access.channel = channel_number; + ccode = get_user_access( &user_access); + if (h->eval_ccode(ccode) != 0) + { + return (-1); + } + user_name.zero(); + user_name.user_id = current_user_id; + ccode = get_user_name( &user_name); + if (ccode == 0xCC) + { + user_name.user_id = current_user_id; + memset(&user_name.user_name, '\0', 17); + } + else if (h->eval_ccode(ccode) != 0) + { + return (-1); + } + if (csv_output) + { + dump_user_access_csv((char *) user_name.user_name, &user_access); + } + else + { + dump_user_access((char *) user_name.user_name, &user_access); + } + ++current_user_id; + } + while ((current_user_id <= user_access.max_user_ids) && (current_user_id <= IPMI_UID_MAX)); + return 0; +} + +/* ipmi_print_user_summary - print User statistics for given channel + * + * @intf - IPMI interface + * @channel_number - channel number + * + * returns - 0 on success, (-1) on error + */ +template<class T> int ipmi_user<T>::print_user_summary(uint8_t channel_number) +{ + struct user_access_t user_access = + { 0 }; + int ccode = 0; + user_access.channel = channel_number; + user_access.user_id = 1; + ccode = get_user_access( &user_access); + if (h->eval_ccode(ccode) != 0) + { + return (-1); + } + if (csv_output) + { + printf("%" PRIu8 ",%" PRIu8 ",%" PRIu8 "\n", user_access.max_user_ids, user_access.enabled_user_ids, + user_access.fixed_user_ids); + } + else + { + printf("Maximum IDs : %" PRIu8 "\n", user_access.max_user_ids); + printf("Enabled User Count : %" PRIu8 "\n", user_access.enabled_user_ids); + printf("Fixed Name Count : %" PRIu8 "\n", user_access.fixed_user_ids); + } + return 0; +} + +/* + * ipmi_user_set_username + */ +template<class T> int ipmi_user<T>::set_user_name(uint8_t user_id, const char *name) +{ + struct ipmi_rs * rsp; + struct ipmi_rq req; + uint8_t msg_data[17]; + + /* + * Ensure there is space for the name in the request message buffer + */ + if (strlen(name) >= sizeof(msg_data)) + { + return -1; + } + req.msg.netfn = IPMI_NETFN_APP; /* 0x06 */ + req.msg.cmd = IPMI_SET_USER_NAME; /* 0x45 */ + req.msg.data = msg_data; + req.msg.data_len = sizeof(msg_data); + memset(msg_data, 0, sizeof(msg_data)); + + /* The channel number will remain constant throughout this function */ + msg_data[0] = user_id; + strncpy((char *) (msg_data + 1), name, sizeof(msg_data)-1); + + rsp = intf->sendrecv( &req); + + if (rsp == NULL) + { + lPrintf(LOG_ERR, "Set User Name command failed (user %d, name %s)", user_id, name); + return -1; + } + if (rsp->ccode > 0) + { + lPrintf(LOG_ERR, "Set User Name command failed (user %d, name %s): %s", user_id, name, + h->val2str(rsp->ccode, completion_code_vals)); + return -1; + } + + return 0; +} + +/* ipmi_user_test_password - Call _ipmi_set_user_password() with operation bit + * set to test password and interpret result. + */ +template<class T> int ipmi_user<T>::user_test_password(uint8_t user_id, const char *password, + uint8_t is_twenty_byte_password) +{ + int ret = 0; + ret = set_user_password( user_id, + IPMI_PASSWORD_TEST_PASSWORD, password, is_twenty_byte_password); + + switch (ret) + { + case 0: + printf("Success\n"); + break; + case 0x80: + printf("Failure: password incorrect\n"); + break; + case 0x81: + printf("Failure: wrong password size\n"); + break; + default: + printf("Unknown error\n"); + } + + return ((ret == 0) ? 0 : -1); +} + +/* + * print_user_usage + */ +static void print_user_usage(void) +{ + lPrintf(LOG_NOTICE, "User Commands:"); + lPrintf(LOG_NOTICE, " summary [<channel number>]"); + lPrintf(LOG_NOTICE, " list [<channel number>]"); + lPrintf(LOG_NOTICE, " set name <user id> <username>"); + lPrintf(LOG_NOTICE, " set password <user id> [<password> <16|20>]"); + lPrintf(LOG_NOTICE, " disable <user id>"); + lPrintf(LOG_NOTICE, " enable <user id>"); + lPrintf(LOG_NOTICE, " priv <user id> <privilege level> [<channel number>]"); + lPrintf(LOG_NOTICE, " Privilege levels:"); + lPrintf(LOG_NOTICE, " * 0x1 - Callback"); + lPrintf(LOG_NOTICE, " * 0x2 - User"); + lPrintf(LOG_NOTICE, " * 0x3 - Operator"); + lPrintf(LOG_NOTICE, " * 0x4 - Administrator"); + lPrintf(LOG_NOTICE, " * 0x5 - OEM Proprietary"); + lPrintf(LOG_NOTICE, " * 0xF - No Access"); + lPrintf(LOG_NOTICE, ""); + lPrintf(LOG_NOTICE, " test <user id> <16|20> [<password]>"); + lPrintf(LOG_NOTICE, ""); +} + +const char * +ipmi_user_build_password_prompt(uint8_t user_id) +{ + static char prompt[128]; + memset(prompt, 0, 128); + snprintf(prompt, 128, "Password for user %d: ", user_id); + return prompt; +} + +/* ask_password - ask user for password + * + * @user_id: User ID which will be built-in into text + * + * @returns pointer to char with password + */ +char * +ask_password(uint8_t user_id) +{ + const char *password_prompt = ipmi_user_build_password_prompt(user_id); +# ifdef HAVE_GETPASSPHRASE + return getpassphrase(password_prompt); +# else + return (char*) getpass(password_prompt); +# endif +} + +template<class T> int ipmi_user<T>::user_summary( int argc, char **argv) +{ + /* Summary*/ + uint8_t channel; + if (argc == 1) + { + channel = 0x0E; /* Ask about the current channel */ + } + else if (argc == 2) + { + if (h->is_ipmi_channel_num(argv[1], &channel) != 0) + { + return (-1); + } + } + else + { + print_user_usage(); + return (-1); + } + return print_user_summary( channel); +} +#if 0 +template<class T> int ipmi_user_list(ipmi_intf<T> *intf, int argc, char **argv) +{ + /* List */ + uint8_t channel; + if (argc == 1) + { + channel = 0x0E; /* Ask about the current channel */ + } + else if (argc == 2) + { + if (h->is_ipmi_channel_num(argv[1], &channel) != 0) + { + return (-1); + } + } + else + { + print_user_usage(); + return (-1); + } + return ipmi_print_user_list(intf, channel); +} +#endif +template<class T> int ipmi_user<T>::user_test(int argc, char **argv) +{ + /* Test */ + char *password = NULL; + int password_length = 0; + uint8_t user_id = 0; + /* a little irritating, isn't it */ + if (argc != 3 && argc != 4) + { + print_user_usage(); + return (-1); + } + if (h->is_ipmi_user_id(argv[1], &user_id)) + { + return (-1); + } + if (h->str2int(argv[2], &password_length) != 0 || (password_length != 16 && password_length != 20)) + { + lPrintf(LOG_ERR, "Given password length '%s' is invalid.", argv[2]); + lPrintf(LOG_ERR, "Expected value is either 16 or 20."); + return (-1); + } + if (argc == 3) + { + /* We need to prompt for a password */ + password = ask_password(user_id); + if (password == NULL) + { + lPrintf(LOG_ERR, "ipmitool: malloc failure"); + return (-1); + } + } + else + { + password = argv[3]; + } + return user_test_password( user_id, password, password_length == 20); +} + +template<class T> int ipmi_user<T>::user_priv( int argc, char **argv) +{ + struct user_access_t user_access = + { 0 }; + int ccode = 0; + + if (argc != 3 && argc != 4) + { + print_user_usage(); + return (-1); + } + if (argc == 4) + { + if (h->is_ipmi_channel_num(argv[3], &user_access.channel) != 0) + { + return (-1); + } + } + else + { + /* Use channel running on */ + user_access.channel = 0x0E; + } + if (h->is_ipmi_user_priv_limit(argv[2], &user_access.privilege_limit) != 0 + || h->is_ipmi_user_id(argv[1], &user_access.user_id) != 0) + { + return (-1); + } + ccode = set_user_access( &user_access, 1); + if (h->eval_ccode(ccode) != 0) + { + lPrintf(LOG_ERR, "Set Privilege Level command failed (user %d)", user_access.user_id); + return (-1); + } + else + { + printf("Set Privilege Level command successful (user %d)\n", user_access.user_id); + return 0; + } +} + +template<class T> int ipmi_user<T>::user_mod(int argc, char **argv) +{ + /* Disable / Enable */ + uint8_t user_id; + uint8_t operation; + uint8_t ccode; + + if (argc != 2) + { + print_user_usage(); + return (-1); + } + if (h->is_ipmi_user_id(argv[1], &user_id)) + { + return (-1); + } + operation = (strncmp(argv[0], "disable", 7) == 0) ? + IPMI_PASSWORD_DISABLE_USER : + IPMI_PASSWORD_ENABLE_USER; + + ccode = set_user_password( user_id, operation, (char *) NULL, 0); + if (h->eval_ccode(ccode) != 0) + { + lPrintf(LOG_ERR, "Set User Password command failed (user %d)", user_id); + return (-1); + } + return 0; +} + +template<class T> int ipmi_user<T>::user_password( int argc, char **argv) +{ + char *password = NULL; + int ccode = 0; + uint8_t password_type = 16; + uint8_t user_id = 0; + if (h->is_ipmi_user_id(argv[2], &user_id)) + { + return (-1); + } + + if (argc == 3) + { + /* We need to prompt for a password */ + char *tmp; + password = ask_password(user_id); + if (password == NULL) + { + lPrintf(LOG_ERR, "ipmitool: malloc failure"); + return (-1); + } + tmp = ask_password(user_id); + if (tmp == NULL) + { + lPrintf(LOG_ERR, "ipmitool: malloc failure"); + return (-1); + } + if (strlen(password) != strlen(tmp) || strncmp(password, tmp, strlen(tmp))) + { + lPrintf(LOG_ERR, "Passwords do not match."); + return (-1); + } + } + else + { + password = argv[3]; + if (argc > 4) + { + if ((h->str2uchar(argv[4], &password_type) != 0) || (password_type != 16 && password_type != 20)) + { + lPrintf(LOG_ERR, "Invalid password length '%s'", argv[4]); + return (-1); + } + } + else + { + password_type = 16; + } + } + + if (password == NULL) + { + lPrintf(LOG_ERR, "Unable to parse password argument."); + return (-1); + } + else if (strlen(password) > 20) + { + lPrintf(LOG_ERR, "Password is too long (> 20 bytes)"); + return (-1); + } + + ccode = set_user_password( user_id, IPMI_PASSWORD_SET_PASSWORD, password, password_type > 16); + if (h->eval_ccode(ccode) != 0) + { + lPrintf(LOG_ERR, "Set User Password command failed (user %d)", user_id); + return (-1); + } + else + { + printf("Set User Password command successful (user %d)\n", user_id); + return 0; + } +} + +template<class T> int ipmi_user<T>::user_name( int argc, char **argv) +{ + /* Set Name */ + uint8_t user_id = 0; + if (argc != 4) + { + print_user_usage(); + return (-1); + } + if (h->is_ipmi_user_id(argv[2], &user_id)) + { + return (-1); + } + if (strlen(argv[3]) > 16) + { + lPrintf(LOG_ERR, "Username is too long (> 16 bytes)"); + return (-1); + } + + return set_user_name(user_id, argv[3]); +} +#if 0 +/* + * ipmi_user_main + * + * Upon entry to this function argv should contain our arguments + * specific to this subcommand + */ +template<class T> int ipmi_user_main(ipmi_intf<T> *intf, int argc, char **argv) +{ + if (argc == 0) + { + lPrintf(LOG_ERR, "Not enough parameters given."); + print_user_usage(); + return (-1); + } + if (strncmp(argv[0], "help", 4) == 0) + { + /* Help */ + print_user_usage(); + return 0; + } + else if (strncmp(argv[0], "summary", 7) == 0) + { + return ipmi_user_summary(intf, argc, argv); + } + else if (strncmp(argv[0], "list", 4) == 0) + { + return ipmi_user_list(intf, argc, argv); + } + else if (strncmp(argv[0], "test", 4) == 0) + { + return ipmi_user_test(intf, argc, argv); + } + else if (strncmp(argv[0], "set", 3) == 0) + { + /* Set */ + if ((argc >= 3) && (strncmp("password", argv[1], 8) == 0)) + { + return ipmi_user_password(intf, argc, argv); + } + else if ((argc >= 2) && (strncmp("name", argv[1], 4) == 0)) + { + return ipmi_user_name(intf, argc, argv); + } + else + { + print_user_usage(); + return (-1); + } + } + else if (strncmp(argv[0], "priv", 4) == 0) + { + return ipmi_user_priv(intf, argc, argv); + } + else if ((strncmp(argv[0], "disable", 7) == 0) || (strncmp(argv[0], "enable", 6) == 0)) + { + return ipmi_user_mod(intf, argc, argv); + } + else + { + lPrintf(LOG_ERR, "Invalid user command: '%s'\n", argv[0]); + print_user_usage(); + return (-1); + } +} +#endif + +template class ipmi_user<lan>; +template class ipmi_user<LANPlus>; diff --git a/Online/IPMI/src/NewLib/ipmi_user.h b/Online/IPMI/src/NewLib/ipmi_user.h new file mode 100755 index 0000000000000000000000000000000000000000..ca880f09498a160eefc8e3639e07b88dec91caf6 --- /dev/null +++ b/Online/IPMI/src/NewLib/ipmi_user.h @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. + * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. + * SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE + * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING + * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL + * SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, + * OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR + * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF + * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, + * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + */ + +#ifndef IPMI_USER_H +#define IPMI_USER_H + +#if HAVE_CONFIG_H +# include "config.h" +#endif +#include "ipmi.h" + +#define IPMI_PASSWORD_DISABLE_USER 0x00 +#define IPMI_PASSWORD_ENABLE_USER 0x01 +#define IPMI_PASSWORD_SET_PASSWORD 0x02 +#define IPMI_PASSWORD_TEST_PASSWORD 0x03 + +#define IPMI_USER_ENABLE_UNSPECIFIED 0x00 +#define IPMI_USER_ENABLE_ENABLED 0x40 +#define IPMI_USER_ENABLE_DISABLED 0x80 +#define IPMI_USER_ENABLE_RESERVED 0xC0 + +/* (22.27) Get and (22.26) Set User Access */ +struct user_access_t { + uint8_t callin_callback=0; + uint8_t channel=0; + uint8_t enabled_user_ids=0; + uint8_t enable_status=0; + uint8_t fixed_user_ids=0; + uint8_t ipmi_messaging=0; + uint8_t link_auth=0; + uint8_t max_user_ids=0; + uint8_t privilege_limit=0; + uint8_t session_limit=0; + uint8_t user_id=0; + void zero() + { + callin_callback=0; + channel=0; + enabled_user_ids=0; + enable_status=0; + fixed_user_ids=0; + ipmi_messaging=0; + link_auth=0; + max_user_ids=0; + privilege_limit=0; + session_limit=0; + user_id=0; + + }; +}; + +/* (22.29) Get User Name */ +struct user_name_t { + uint8_t user_id=0; + uint8_t user_name[17]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + void zero() + { + user_id = 0; + memset(user_name,0,sizeof(user_name)); + } +}; +template <class T> class ipmi_intf; +template <class T> class ipmi_helper; +template <class T> class ipmi_user +{ + public: +// ipmi_user(ipmi_intf<T> *i); + ipmi_helper<T> *h; + ipmi_intf<T> *intf; + ipmi_user(ipmi_intf<T> *i); + int get_user_access( struct user_access_t *user_access_rsp); + int get_user_name( struct user_name_t *user_name_ptr); + int set_user_access( struct user_access_t *user_access_req, + uint8_t change_priv_limit_only); + int set_user_password( uint8_t user_id, uint8_t operation, const char *password, uint8_t is_twenty_byte); + void dump_user_access(const char *user_name, struct user_access_t *user_access); + void dump_user_access_csv(const char *user_name, struct user_access_t *user_access); + int print_user_list(uint8_t channel_number); + int print_user_summary(uint8_t channel_number); + int set_user_name(uint8_t user_id, const char *name); + int user_test_password(uint8_t user_id, const char *password,uint8_t is_twenty_byte_password); + int user_summary( int argc, char **argv); + int user_test( int argc, char **argv); + int user_priv( int argc, char **argv); + int user_mod( int argc, char **argv); + int user_password( int argc, char **argv); + int user_name( int argc, char **argv); + + +}; +#endif /* IPMI_USER_H */ diff --git a/Online/IPMI/src/NewLib/ipmilight.cpp b/Online/IPMI/src/NewLib/ipmilight.cpp deleted file mode 100644 index 2e5657ec8d68a032f248a8e1f9f05350d4219716..0000000000000000000000000000000000000000 --- a/Online/IPMI/src/NewLib/ipmilight.cpp +++ /dev/null @@ -1,383 +0,0 @@ -//========================================================================== -// LHCb Online software suite -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see OnlineSys/LICENSE. -// -// Author : B.Jost -// -//========================================================================== -/* - * ipmilight.c - * - * Created on: Jan 18, 2016 - * Author: beat - */ - -#include <stdlib.h> -#include <stdio.h> -#include <inttypes.h> -#include <signal.h> -#include <string.h> -#include <strings.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> -#include <fcntl.h> -#include <errno.h> -#include <ctype.h> - -#include "ipmilight.h" -//#include <ipmitool/helper.h> -//#include <ipmitool/log.h> -//#include <ipmitool/ipmi.h> -//#include <ipmitool/ipmi_intf.h> -//#include <ipmitool/ipmi_session.h> -//#include <ipmitool/ipmi_sdr.h> -//#include <ipmitool/ipmi_gendev.h> -//#include <ipmitool/ipmi_sel.h> -//#include <ipmitool/ipmi_fru.h> -//#include <ipmitool/ipmi_sol.h> -//#include <ipmitool/ipmi_isol.h> -//#include <ipmitool/ipmi_lanp.h> -//#include <ipmitool/ipmi_chassis.h> -//#include <ipmitool/ipmi_mc.h> -//#include <ipmitool/ipmi_firewall.h> -//#include <ipmitool/ipmi_sensor.h> -//#include <ipmitool/ipmi_channel.h> -//#include <ipmitool/ipmi_session.h> -//#include <ipmitool/ipmi_event.h> -//#include <ipmitool/ipmi_user.h> -//#include <ipmitool/ipmi_raw.h> -//#include <ipmitool/ipmi_pef.h> -//#include <ipmitool/ipmi_oem.h> -//#include <ipmitool/ipmi_ekanalyzer.h> -//#include <ipmitool/ipmi_picmg.h> -#include "ipmi_constants.h" -#include "log.h" -#include "ipmi_intf.h" -#include "ipmi_oem.h" - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#ifdef ENABLE_ALL_OPTIONS -# define OPTION_STRING "I:hVvcgsEKYao:H:d:P:f:U:p:C:L:A:t:T:m:z:S:l:b:B:e:k:y:O:R:N:D:" -#else -# define OPTION_STRING "I:hVvcH:f:U:p:d:S:D:" -#endif - -int verbose; -int csv_output; -extern const struct valstr ipmi_privlvl_vals[]; -extern const struct valstr ipmi_authtype_session_vals[]; -void ipmi_catch_sigint(); -#define SOL_ESCAPE_CHARACTER_DEFAULT '~' - -//ipmi_intf_support * sup; -int privlvl = 0; -uint8_t target_addr = 0; -uint8_t target_channel = 0; - -uint8_t transit_addr = 0; -uint8_t transit_channel = 0; -uint8_t target_lun = 0; -uint8_t arg_addr = 0; -uint8_t addr = 0; -uint16_t my_long_packet_size = 0; -uint8_t my_long_packet_set = 0; -uint8_t lookupbit = 0x10; /* use name-only lookup by default */ -int retry = 0; -uint32_t timeout = 0; -int authtype = -1; -char * tmp_pass = NULL; -char * tmp_env = NULL; -char * hostname = NULL; -char * username = NULL; -char * password = NULL; -char * intfname = NULL; -char * progname = NULL; -char * oemtype = NULL; -char * sdrcache = NULL; -unsigned char * kgkey = NULL; -char * seloem = NULL; -int port = 0; -int devnum = 0; -int cipher_suite_id = 3; /* See table 22-19 of the IPMIv2 spec */ -int argflag, i, found; -int rc = -1; -char sol_escape_char = SOL_ESCAPE_CHARACTER_DEFAULT; -char * devfile = NULL; - -ipmi_intf *ipmi_light_init_intf(char *hname, char *uname, char *pword) -// , -// struct ipmi_cmd * cmdlist) -{ - intfname = strdup("lan"); return 0; - - username = strdup(uname); - hostname = strdup(hname); - password = strdup(pword); - ipmi_intf *ipmi_main_intf = new ipmi_intf(); //*ipmi_main_intf,*IntfPatt; - -// if (ipmi_main_intf == 0) -// { -// return (void*)-1; -// } -// if (hostname != NULL && password == NULL && -// (authtype != IPMI_SESSION_AUTHTYPE_NONE || authtype < 0)) { -//#ifdef HAVE_GETPASSPHRASE -// tmp_pass = getpassphrase("Password: "); -//#else -// tmp_pass = getpass("Password: "); -//#endif -// if (tmp_pass != NULL) { -// password = strdup(tmp_pass); -// tmp_pass = NULL; -// if (password == NULL) { -// lPrintf(LOG_ERR, "%s: malloc failure", progname); -// goto out_free; -// } -// } -// } - - /* if no interface was specified but a - * hostname was then use LAN by default - * otherwise the default is hardcoded - * to use the first entry in the list - */ - ipmi_main_intf = ipmi_main_intf->ipmi_intf_load(intfname); - /* setup log */ - log_init(progname, 0, verbose); - - /* run OEM setup if found */ - if (oemtype != NULL && ipmi_oem_setup(ipmi_main_intf, oemtype) < 0) - { - lPrintf(LOG_ERR, "OEM setup for \"%s\" failed", oemtype); - ipmi_light_Cleanup(ipmi_main_intf); - return 0; - } - - /* set session variables */ - if (hostname != NULL) - ipmi_main_intf->ipmi_intf_session_set_hostname(hostname); - if (username != NULL) - ipmi_main_intf->ipmi_intf_session_set_username(username); - if (password != NULL) - ipmi_main_intf->ipmi_intf_session_set_password(password); - if (kgkey != NULL) - ipmi_main_intf->ipmi_intf_session_set_kgkey((char*) kgkey); - if (port > 0) - ipmi_main_intf->ipmi_intf_session_set_port(port); - if (authtype >= 0) - ipmi_main_intf->ipmi_intf_session_set_authtype((uint8_t) authtype); - if (privlvl > 0) - ipmi_main_intf->ipmi_intf_session_set_privlvl((uint8_t) privlvl); - else - ipmi_main_intf->ipmi_intf_session_set_privlvl(IPMI_SESSION_PRIV_ADMIN); /* default */ - /* Adding retry and timeout for interface that support it */ - if (retry > 0) - ipmi_main_intf->ipmi_intf_session_set_retry(retry); - if (timeout > 0) - ipmi_main_intf->ipmi_intf_session_set_timeout(timeout); - - ipmi_main_intf->ipmi_intf_session_set_lookupbit(lookupbit); - ipmi_main_intf->ipmi_intf_session_set_sol_escape_char(sol_escape_char); - ipmi_main_intf->ipmi_intf_session_set_cipher_suite_id(cipher_suite_id); - - ipmi_main_intf->devnum = devnum; - - /* setup device file if given */ - ipmi_main_intf->devfile = devfile; - - /* Open the interface with the specified or default IPMB address */ - ipmi_main_intf->my_addr = arg_addr ? arg_addr : IPMI_BMC_SLAVE_ADDR; - if (ipmi_main_intf->open() < 0) - { - ipmi_light_Cleanup(ipmi_main_intf); - return 0; - } - /* - * Attempt picmg discovery of the actual interface address unless - * the users specified an address. - * Address specification always overrides discovery - */ -// if (picmg_discover(ipmi_main_intf) && !arg_addr) -// { -// lPrintf(LOG_DEBUG, "Running PICMG Get Address Info"); -// addr = ipmi_main_intf->ipmi_picmg_ipmb_address(); -// lPrintf(LOG_INFO, "Discovered IPMB-0 address 0x%x", addr); -// } - - /* - * If we discovered the ipmb address and it is not the same as what we - * used for open, Set the discovered IPMB address as my address if the - * interface supports it. - */ -// if (addr != 0 && addr != ipmi_main_intf->my_addr -// && ipmi_main_intf->set_my_addr) -// { -// /* -// * Only set the interface address on interfaces which support -// * it -// */ -// (void) ipmi_main_intf->set_my_addr(ipmi_main_intf, addr); -// } -// - /* If bridging addresses are specified, handle them */ - if (target_addr > 0) - { - ipmi_main_intf->target_addr = target_addr; - ipmi_main_intf->target_lun = target_lun; - ipmi_main_intf->target_channel = target_channel; - } - if (transit_addr > 0) - { - /* sanity check, transit makes no sense without a target */ - if ((transit_addr != 0 || transit_channel != 0) - && ipmi_main_intf->target_addr == 0) - { - lPrintf(LOG_ERR, "Transit address/channel %#x/%#x ignored. " - "Target address must be specified!", transit_addr, transit_channel); - ipmi_light_Cleanup(ipmi_main_intf); - return 0; - } - - ipmi_main_intf->transit_addr = transit_addr; - ipmi_main_intf->transit_channel = transit_channel; - } - if (ipmi_main_intf->target_addr > 0) - { - /* must be admin level to do this over lan */ - ipmi_main_intf->ipmi_intf_session_set_privlvl( IPMI_SESSION_PRIV_ADMIN); - /* Get the ipmb address of the targeted entity */ -// ipmi_main_intf->target_ipmb_addr = -// ipmi_main_intf->ipmi_picmg_ipmb_address(); - lPrintf(LOG_DEBUG, - "Specified addressing Target %#x:%#x Transit %#x:%#x", - ipmi_main_intf->target_addr, ipmi_main_intf->target_channel, - ipmi_main_intf->transit_addr, ipmi_main_intf->transit_channel); - if (ipmi_main_intf->target_ipmb_addr) - { - lPrintf(LOG_INFO, "Discovered Target IPMB-0 address %#x", - ipmi_main_intf->target_ipmb_addr); - } - } - - lPrintf(LOG_DEBUG, "Interface address: my_addr %#x " - "transit %#x:%#x target %#x:%#x " - "ipmb_target %#x\n", ipmi_main_intf->my_addr, - ipmi_main_intf->transit_addr, ipmi_main_intf->transit_channel, - ipmi_main_intf->target_addr, ipmi_main_intf->target_channel, - ipmi_main_intf->target_ipmb_addr); - - /* parse local SDR cache if given */ -// if (sdrcache != NULL) -// { -// ipmi_sdr_list_cache_fromfile(ipmi_main_intf, sdrcache); -// } -// /* Parse SEL OEM file if given */ -// if (seloem != NULL) -// { -// ipmi_oem_setup(ipmi_main_intf); ipmi_sel_oem_init(seloem); -// } - -// /* Enable Big Buffer when requested */ -// if ( my_long_packet_size != 0 ) { -// /* Enable Big Buffer when requested */ -// if (!ipmi_oem_active( ipmi_main_intf,"kontron") || -// ipmi_main_intf->ipmi_kontronoem_set_large_buffer(my_long_packet_size ) == 0) { -// Printf("Setting large buffer to %i\n",my_long_packet_size); -// my_long_packet_set = 1; -// ipmi_main_intf->ipmi_intf_set_max_request_data_size( -// my_long_packet_size); -// } -// } - -// ipmi_main_intf->cmdlist = cmdlist; -// memcpy(IntfPatt,ipmi_main_intf,sizeof (struct ipmi_intf)); - return ipmi_main_intf; -} - -#if 0 -int ipmi_light_do_it(ipmi_intf *ipmi_main_intf, int argc, char ** argv) -{ - /* save program name */ - progname = strrchr(argv[0], '/'); - progname = ((progname == NULL) ? argv[0] : progname + 1); -// signal(SIGINT, ipmi_catch_sigint); - - /* now we finally run the command */ - if (argc > 0) - rc = ipmi_main_intf->ipmi_cmd_run(argv[1], argc - 1, &(argv[2])); - else - rc = ipmi_main_intf->ipmi_cmd_run( NULL, 0, NULL); - return rc; -} -#endif -int ipmi_light_Cleanup(ipmi_intf *ipmi_main_intf) -{ - /* clean repository caches */ -// ipmi_cleanup(ipmi_main_intf); - - /* call interface close function if available */ - if (ipmi_main_intf->opened > 0) - ipmi_main_intf->ipmi_close(); - - log_halt(); - - if (intfname != NULL) - { - free(intfname); - intfname = NULL; - } - if (hostname != NULL) - { - free(hostname); - hostname = NULL; - } - if (username != NULL) - { - free(username); - username = NULL; - } - if (password != NULL) - { - free(password); - password = NULL; - } - if (oemtype != NULL) - { - free(oemtype); - oemtype = NULL; - } - if (seloem != NULL) - { - free(seloem); - seloem = NULL; - } - if (kgkey != NULL) - { - free(kgkey); - kgkey = NULL; - } - if (sdrcache != NULL) - { - free(sdrcache); - sdrcache = NULL; - } - if (devfile) - { - free(devfile); - devfile = NULL; - } - if (ipmi_main_intf) - { - delete (ipmi_main_intf); - ipmi_main_intf = 0; - } - return 0; -} diff --git a/Online/IPMI/src/NewLib/ipmilight.h b/Online/IPMI/src/NewLib/ipmilight.h deleted file mode 100644 index 3cfd03eeab0043f42bcfceae9d911a273f9bda59..0000000000000000000000000000000000000000 --- a/Online/IPMI/src/NewLib/ipmilight.h +++ /dev/null @@ -1,21 +0,0 @@ -//========================================================================== -// LHCb Online software suite -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see OnlineSys/LICENSE. -// -// Author : B.Jost -// -//========================================================================== -#include "ipmi_intf.h" -#include "ipmi_chassis.h" - ipmi_intf * ipmi_light_init_intf( char *hname, - char *uname, - char *pword); -// , -//struct ipmi_cmd * cmdlist); -//int ipmi_light_do_it( ipmi_intf *ipmi_main_intf,int argc, char ** argv); -int ipmi_light_Cleanup( ipmi_intf *ipmi_main_intf); - diff --git a/Online/IPMI/src/NewLib/lan.cpp b/Online/IPMI/src/NewLib/lan.cpp index 209c35ed595c5a96187d9ca5c9ed9d329d26bbc3..c4e7fb0a17b21c3999af71a4863cc9d02f980bd4 100644 --- a/Online/IPMI/src/NewLib/lan.cpp +++ b/Online/IPMI/src/NewLib/lan.cpp @@ -88,32 +88,34 @@ extern const struct valstr ipmi_privlvl_vals[]; extern const struct valstr ipmi_authtype_session_vals[]; //extern int verbose; -lan::lan() -{ - strcpy(name, "lan"); - strcpy(desc, "IPMI v1.5 LAN Interface"); - ipmi_req_entries = 0; - ipmi_req_entries_tail = 0; - bridge_possible = 0; - auth = new ipmi_auth(); -} +//lan::lan(ipmi_intf<lan> *intf) +//{ +// strcpy(name, "lan"); +// strcpy(desc, "IPMI v1.5 LAN Interface"); +// ipmi_req_entries = 0; +// ipmi_req_entries_tail = 0; +// bridge_possible = 0; +// auth = new ipmi_auth(); +// Intf = intf; +// sessionsup_fail = false; +// +//} lan::~lan() { if (auth != 0){ delete auth;auth=0;} } - -struct ipmi_rq_entry *lan::ipmi_req_add_entry(ipmi_intf * intf, struct ipmi_rq * req, uint8_t req_seq) +ipmi_rq_entry<lan> *lan::ipmi_req_add_entry(ipmi_rq * req, uint8_t req_seq) { - struct ipmi_rq_entry *e; + ipmi_rq_entry<lan> *e; - e = (struct ipmi_rq_entry *) malloc(sizeof(struct ipmi_rq_entry)); + e = (ipmi_rq_entry<lan> *) malloc(sizeof( ipmi_rq_entry<lan>)); if (e == NULL) { lPrintf(LOG_ERR, "ipmitool: malloc failure"); return NULL; } - - memset(e, 0, sizeof(struct ipmi_rq_entry)); + e->zero(); +// memset(e, 0, sizeof(ipmi_rq_entry<lan>)); memcpy(&e->req, req, sizeof(struct ipmi_rq)); e->intf = intf; @@ -130,9 +132,9 @@ struct ipmi_rq_entry *lan::ipmi_req_add_entry(ipmi_intf * intf, struct ipmi_rq * return e; } -struct ipmi_rq_entry *lan::ipmi_req_lookup_entry(uint8_t seq, uint8_t cmd) +ipmi_rq_entry<lan> *lan::ipmi_req_lookup_entry(uint8_t seq, uint8_t cmd) { - struct ipmi_rq_entry * e = ipmi_req_entries; + ipmi_rq_entry<lan> * e = ipmi_req_entries; while (e && (e->rq_seq != seq || e->req.msg.cmd != cmd)) { if (e->next == NULL || e == e->next) @@ -144,7 +146,7 @@ struct ipmi_rq_entry *lan::ipmi_req_lookup_entry(uint8_t seq, uint8_t cmd) void lan::ipmi_req_remove_entry(uint8_t seq, uint8_t cmd) { - struct ipmi_rq_entry * p, *e, *saved_next_entry; + ipmi_rq_entry<lan> * p, *e, *saved_next_entry; e = p = ipmi_req_entries; @@ -187,7 +189,7 @@ void lan::ipmi_req_remove_entry(uint8_t seq, uint8_t cmd) void lan::ipmi_req_clear_entries(void) { - struct ipmi_rq_entry * p, *e; + ipmi_rq_entry<lan> * p, *e; e = ipmi_req_entries; while (e) @@ -212,7 +214,7 @@ void lan::ipmi_req_clear_entries(void) int lan::get_random(void *data, int len) { - int fd = open("/dev/urandom", O_RDONLY); + int fd = ::open("/dev/urandom", O_RDONLY); int rv; if (fd < 0) @@ -229,7 +231,7 @@ int lan::get_random(void *data, int len) return rv; } -int lan::ipmi_lan_send_packet(ipmi_intf * intf, uint8_t * data, int data_len) +int lan::ipmi_lan_send_packet( uint8_t * data, int data_len) { if (verbose > 2) intf->helper->printbuf(data, data_len, "send_packet"); @@ -237,7 +239,7 @@ int lan::ipmi_lan_send_packet(ipmi_intf * intf, uint8_t * data, int data_len) return send(intf->fd, data, data_len, 0); } -struct ipmi_rs *lan::ipmi_lan_recv_packet(ipmi_intf * intf, struct ipmi_rs *rsp) +struct ipmi_rs *lan::ipmi_lan_recv_packet( struct ipmi_rs *rsp) { fd_set read_set, err_set; @@ -350,7 +352,7 @@ struct ipmi_rs *lan::ipmi_lan_recv_packet(ipmi_intf * intf, struct ipmi_rs *rsp) * asf.data[9] = 0x00 // supported interactions (reserved) * asf.data[f:a]= 0x000000000000 */ -int lan::ipmi_handle_pong(ipmi_intf * , struct ipmi_rs * rsp) +int lan::ipmi_handle_pong( struct ipmi_rs * rsp) { struct rmcp_pong * pong; @@ -391,7 +393,7 @@ int lan::ipmi_handle_pong(ipmi_intf * , struct ipmi_rs * rsp) * asf.len = 0x00 * */ -int lan::ipmi_lan_ping(ipmi_intf * intf) +int lan::ipmi_lan_ping() { struct asf_hdr asf_ping; asf_ping.iana = htonl(ASF_RMCP_IANA); @@ -417,7 +419,7 @@ int lan::ipmi_lan_ping(ipmi_intf * intf) lPrintf(LOG_DEBUG, "Sending IPMI/RMCP presence ping packet"); - rv = ipmi_lan_send_packet(intf, data, len); + rv = ipmi_lan_send_packet( data, len); free(data); data = NULL; @@ -428,7 +430,7 @@ int lan::ipmi_lan_ping(ipmi_intf * intf) return -1; } ipmi_rs rs; - if (lan::ipmi_lan_poll_recv(intf, &rs) == 0) + if (lan::ipmi_lan_poll_recv(&rs) == 0) return 0; return 1; @@ -439,33 +441,33 @@ int lan::ipmi_lan_ping(ipmi_intf * intf) * request message. This may kick-start some BMCs that get confused with * bad passwords or operate poorly under heavy network load. */ -void lan::ipmi_lan_thump_first(ipmi_intf * intf) +void lan::ipmi_lan_thump_first() { /* is this random data? */ uint8_t data[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x20, 0x18, 0xc8, 0xc2, 0x01, 0x01, 0x3c }; - lan::ipmi_lan_send_packet(intf, data, 16); + lan::ipmi_lan_send_packet( data, 16); } -void lan::ipmi_lan_thump(ipmi_intf * intf) +void lan::ipmi_lan_thump() { uint8_t data[10] = "thump"; - lan::ipmi_lan_send_packet(intf, data, 10); + lan::ipmi_lan_send_packet( data, 10); } -struct ipmi_rs *lan::ipmi_lan_poll_recv(ipmi_intf * intf, struct ipmi_rs *rsp) +struct ipmi_rs *lan::ipmi_lan_poll_recv( struct ipmi_rs *rsp) { struct rmcp_hdr rmcp_rsp; // struct ipmi_rs * rsp; - struct ipmi_rq_entry * entry; + ipmi_rq_entry<lan> * entry; int x = 0, rv; uint8_t our_address = intf->my_addr; if (our_address == 0) our_address = IPMI_BMC_SLAVE_ADDR; - rsp = lan::ipmi_lan_recv_packet(intf, rsp); + rsp = lan::ipmi_lan_recv_packet( rsp); while (rsp != NULL) { @@ -477,14 +479,14 @@ struct ipmi_rs *lan::ipmi_lan_poll_recv(ipmi_intf * intf, struct ipmi_rs *rsp) { case RMCP_CLASS_ASF: /* ping response packet */ - rv = ipmi_handle_pong(intf, rsp); + rv = ipmi_handle_pong( rsp); return (rv <= 0) ? NULL : rsp; case RMCP_CLASS_IPMI: /* handled by rest of function */ break; default: lPrintf(LOG_DEBUG, "Invalid RMCP class: %x", rmcp_rsp.Class); - rsp = lan::ipmi_lan_recv_packet(intf, rsp); + rsp = lan::ipmi_lan_recv_packet( rsp); continue; } @@ -612,7 +614,7 @@ struct ipmi_rs *lan::ipmi_lan_poll_recv(ipmi_intf * intf, struct ipmi_rs *rsp) entry->bridging_level--; if (rsp->data_len - x - 1 == 0) { - rsp = !rsp->ccode ? lan::ipmi_lan_recv_packet(intf, rsp) : NULL; + rsp = !rsp->ccode ? lan::ipmi_lan_recv_packet( rsp) : NULL; if (!entry->bridging_level) entry->req.msg.cmd = entry->req.msg.target_cmd; if (rsp == NULL) @@ -647,7 +649,7 @@ struct ipmi_rs *lan::ipmi_lan_poll_recv(ipmi_intf * intf, struct ipmi_rs *rsp) else { lPrintf(LOG_INFO, "IPMI Request Match NOT FOUND"); - rsp = lan::ipmi_lan_recv_packet(intf, rsp); + rsp = lan::ipmi_lan_recv_packet( rsp); continue; } } @@ -696,7 +698,7 @@ struct ipmi_rs *lan::ipmi_lan_poll_recv(ipmi_intf * intf, struct ipmi_rs *rsp) * | checksum | 1 byte * +--------------------+ */ -struct ipmi_rq_entry *lan::ipmi_lan_build_cmd(ipmi_intf * intf,struct ipmi_rq * req, int isRetry) +ipmi_rq_entry<lan> *lan::ipmi_lan_build_cmd(struct ipmi_rq * req, int isRetry) { struct rmcp_hdr rmcp; ::memset(&rmcp,0,sizeof(rmcp)); @@ -708,8 +710,8 @@ struct ipmi_rq_entry *lan::ipmi_lan_build_cmd(ipmi_intf * intf,struct ipmi_rq * int ap = 0; int len = 0; int cs2 = 0, cs3 = 0; - struct ipmi_rq_entry * entry; - struct ipmi_session * s = intf->session; + ipmi_rq_entry<lan> * entry; + ipmi_session<lan> * s = intf->session; int curr_seq = 0; uint8_t our_address = intf->my_addr; @@ -745,7 +747,7 @@ struct ipmi_rq_entry *lan::ipmi_lan_build_cmd(ipmi_intf * intf,struct ipmi_rq * { // We dont have this request in the list so we can add it // to the list - entry = ipmi_req_add_entry(intf, req, curr_seq); + entry = ipmi_req_add_entry( req, curr_seq); if (entry == NULL) return NULL; } @@ -921,9 +923,9 @@ struct ipmi_rq_entry *lan::ipmi_lan_build_cmd(ipmi_intf * intf,struct ipmi_rq * return entry; } -struct ipmi_rs *lan::ipmi_lan_send_cmd(ipmi_intf * intf, struct ipmi_rq * req,struct ipmi_rs * rsp) +struct ipmi_rs *lan::ipmi_send_cmd( struct ipmi_rq * req,struct ipmi_rs * rsp) { - struct ipmi_rq_entry * entry; + ipmi_rq_entry<lan> * entry; // struct ipmi_rs * rsp = NULL; int itry = 0; int isRetry = 0; @@ -933,7 +935,7 @@ struct ipmi_rs *lan::ipmi_lan_send_cmd(ipmi_intf * intf, struct ipmi_rq * req,st if (intf->opened == 0) { - if (intf->open() < 0) + if (intf->ipmi_open() < 0) { lPrintf(LOG_DEBUG, "Failed to open LAN interface"); return NULL; @@ -945,14 +947,14 @@ struct ipmi_rs *lan::ipmi_lan_send_cmd(ipmi_intf * intf, struct ipmi_rq * req,st { isRetry = (itry > 0) ? 1 : 0; - entry = lan::ipmi_lan_build_cmd(intf, req, isRetry); + entry = lan::ipmi_lan_build_cmd( req, isRetry); if (entry == NULL) { lPrintf(LOG_ERR, "Aborting send command, unable to build"); return NULL; } - if (lan::ipmi_lan_send_packet(intf, entry->msg_data, entry->msg_len) < 0) + if (ipmi_lan_send_packet( entry->msg_data, entry->msg_len) < 0) { itry++; usleep(5000); @@ -964,12 +966,12 @@ struct ipmi_rs *lan::ipmi_lan_send_cmd(ipmi_intf * intf, struct ipmi_rq * req,st if (intf->noanswer) break; - if (ipmi_oem_active(intf, "intelwv2")) - lan::ipmi_lan_thump(intf); + if (oemO->ipmi_oem_active( "intelwv2")) + lan::ipmi_lan_thump(); usleep(100); - rsp = lan::ipmi_lan_poll_recv(intf, rsp); + rsp = lan::ipmi_lan_poll_recv( rsp); /* Duplicate Request ccode most likely indicates a response to a previous retry. Ignore and keep polling. */ @@ -977,7 +979,7 @@ struct ipmi_rs *lan::ipmi_lan_send_cmd(ipmi_intf * intf, struct ipmi_rq * req,st { lPrintf(LOG_ERR, "lan_send_cmd: duplicate ccode..."); rsp = NULL; - rsp = lan::ipmi_lan_poll_recv(intf, rsp); + rsp = lan::ipmi_lan_poll_recv( rsp); } if (rsp) @@ -1018,14 +1020,14 @@ struct ipmi_rs *lan::ipmi_lan_send_cmd(ipmi_intf * intf, struct ipmi_rq * req,st return rsp; } -uint8_t *lan::ipmi_lan_build_rsp(ipmi_intf * intf, struct ipmi_rs * rsp, +uint8_t *lan::ipmi_lan_build_rsp( struct ipmi_rs * rsp, int * llen) { struct rmcp_hdr rmcp; rmcp.ver = RMCP_VERSION_1; rmcp.Class = RMCP_CLASS_IPMI; rmcp.seq = 0xff; - struct ipmi_session * s = intf->session; + ipmi_session<lan> * s = intf->session; int cs, mp, ap = 0, tmp; int len; uint8_t * msg; @@ -1116,13 +1118,13 @@ uint8_t *lan::ipmi_lan_build_rsp(ipmi_intf * intf, struct ipmi_rs * rsp, return msg; } -int lan::ipmi_lan_send_rsp(ipmi_intf * intf, struct ipmi_rs * rsp) +int lan::ipmi_lan_send_rsp( struct ipmi_rs * rsp) { uint8_t * msg; int len = 0; int rv; - msg = lan::ipmi_lan_build_rsp(intf, rsp, &len); + msg = lan::ipmi_lan_build_rsp( rsp, &len); if (len <= 0 || msg == NULL) { lPrintf(LOG_ERR, "Invalid response packet"); @@ -1178,14 +1180,13 @@ int lan::ipmi_lan_send_rsp(ipmi_intf * intf, struct ipmi_rs * rsp) * | [request data] | data_len bytes * +--------------------+ */ -uint8_t *lan::ipmi_lan_build_sol_msg(ipmi_intf * intf, - struct ipmi_v2_payload * payload, int * llen) +uint8_t *lan::ipmi_lan_build_sol_msg(struct ipmi_v2_payload * payload, int * llen) { struct rmcp_hdr rmcp; rmcp.ver = RMCP_VERSION_1; rmcp.Class = RMCP_CLASS_IPMI; rmcp.seq = 0xff; - struct ipmi_session * session = intf->session; + ipmi_session<lan> * session = intf->session; /* msg will hold the entire message to be sent */ uint8_t * msg; @@ -1277,7 +1278,7 @@ int lan::sol_response_acks_packet(struct ipmi_rs *rsp, * lan::ipmi_lan_send_sol_payload * */ -struct ipmi_rs *lan::ipmi_lan_send_sol_payload(ipmi_intf * intf,struct ipmi_v2_payload * payload,struct ipmi_rs *rsp) +struct ipmi_rs *lan::ipmi_lan_send_sol_payload(struct ipmi_v2_payload * payload,struct ipmi_rs *rsp) { // struct ipmi_rs rsp; uint8_t * msg; @@ -1286,11 +1287,11 @@ struct ipmi_rs *lan::ipmi_lan_send_sol_payload(ipmi_intf * intf,struct ipmi_v2_p if (intf->opened == 0 ) { - if (intf->open() < 0) + if (intf->ipmi_open() < 0) return NULL; } - msg = lan::ipmi_lan_build_sol_msg(intf, payload, &len); + msg = lan::ipmi_lan_build_sol_msg( payload, &len); if (len <= 0 || msg == NULL) { lPrintf(LOG_ERR, "Invalid SOL payload packet"); @@ -1306,7 +1307,7 @@ struct ipmi_rs *lan::ipmi_lan_send_sol_payload(ipmi_intf * intf,struct ipmi_v2_p for (;;) { - if (ipmi_lan_send_packet(intf, msg, len) < 0) + if (ipmi_lan_send_packet( msg, len) < 0) { itry++; usleep(5000); @@ -1325,7 +1326,7 @@ struct ipmi_rs *lan::ipmi_lan_send_sol_payload(ipmi_intf * intf,struct ipmi_v2_p usleep(100); - rsp = ipmi_lan_recv_sol(intf, rsp); /* Grab the next packet */ + rsp = ipmi_lan_recv_sol( rsp); /* Grab the next packet */ if (sol_response_acks_packet(rsp, payload)) break; @@ -1391,7 +1392,7 @@ int lan::is_sol_partial_ack(struct ipmi_v2_payload *v2_payload,struct ipmi_rs *r /* * set_sol_packet_sequence_number */ -void lan::set_sol_packet_sequence_number(ipmi_intf *intf,struct ipmi_v2_payload *v2_payload) +void lan::set_sol_packet_sequence_number(struct ipmi_v2_payload *v2_payload) { /* Keep our sequence number sane */ if (intf->session->sol_data.sequence_number > 0x0F) @@ -1410,7 +1411,7 @@ void lan::set_sol_packet_sequence_number(ipmi_intf *intf,struct ipmi_v2_payload * 0 on failure * */ -struct ipmi_rs *lan::ipmi_lan_send_sol(ipmi_intf * intf,struct ipmi_v2_payload * v2_payload, struct ipmi_rs * rsp) +struct ipmi_rs *lan::ipmi_lan_send_sol(struct ipmi_v2_payload * v2_payload, struct ipmi_rs * rsp) { // struct ipmi_rs * rsp; int chars_to_resend = 0; @@ -1423,11 +1424,11 @@ struct ipmi_rs *lan::ipmi_lan_send_sol(ipmi_intf * intf,struct ipmi_v2_payload * */ v2_payload->payload.sol_packet.acked_packet_number = 0; /* NA */ - set_sol_packet_sequence_number(intf, v2_payload); + set_sol_packet_sequence_number( v2_payload); v2_payload->payload.sol_packet.accepted_character_count = 0; /* NA */ - rsp = lan::ipmi_lan_send_sol_payload(intf, v2_payload,rsp); + rsp = lan::ipmi_lan_send_sol_payload( v2_payload,rsp); /* Determine if we need to resend some of our data */ chars_to_resend = is_sol_partial_ack(v2_payload, rsp); @@ -1441,7 +1442,7 @@ struct ipmi_rs *lan::ipmi_lan_send_sol(ipmi_intf * intf,struct ipmi_v2_payload * if (rsp->data_len) intf->session->sol_data.sol_input_handler(rsp); - set_sol_packet_sequence_number(intf, v2_payload); + set_sol_packet_sequence_number( v2_payload); /* Just send the required data */ memmove(v2_payload->payload.sol_packet.data, @@ -1451,7 +1452,7 @@ struct ipmi_rs *lan::ipmi_lan_send_sol(ipmi_intf * intf,struct ipmi_v2_payload * v2_payload->payload.sol_packet.character_count = chars_to_resend; - rsp = lan::ipmi_lan_send_sol_payload(intf, v2_payload,rsp); + rsp = lan::ipmi_lan_send_sol_payload( v2_payload,rsp); chars_to_resend = is_sol_partial_ack(v2_payload, rsp); } @@ -1471,7 +1472,7 @@ struct ipmi_rs *lan::ipmi_lan_send_sol(ipmi_intf * intf,struct ipmi_v2_payload * * It also "Remembers" the data so we don't get repeats. * */ -int lan::check_sol_packet_for_new_data(ipmi_intf * , struct ipmi_rs *rsp) +int lan::check_sol_packet_for_new_data(struct ipmi_rs *rsp) { uint8_t last_received_sequence_number = 0; uint8_t last_received_byte_count = 0; @@ -1519,7 +1520,7 @@ int lan::check_sol_packet_for_new_data(ipmi_intf * , struct ipmi_rs *rsp) * * Provided the specified packet looks reasonable, ACK it. */ -void lan::ack_sol_packet(ipmi_intf * intf, struct ipmi_rs * rsp) +void lan::ack_sol_packet( struct ipmi_rs * rsp) { if (rsp && (rsp->session.payloadtype == IPMI_PAYLOAD_TYPE_SOL) && (rsp->payload.sol_packet.packet_sequence_number)) @@ -1544,7 +1545,7 @@ void lan::ack_sol_packet(ipmi_intf * intf, struct ipmi_rs * rsp) ack.payload.sol_packet.accepted_character_count = rsp->data_len; - ipmi_lan_send_sol_payload(intf, &ack,rsp); + ipmi_lan_send_sol_payload( &ack,rsp); } } @@ -1554,23 +1555,23 @@ void lan::ack_sol_packet(ipmi_intf * intf, struct ipmi_rs * rsp) * Receive a SOL packet and send an ACK in response. * */ -struct ipmi_rs *lan::ipmi_lan_recv_sol(ipmi_intf * intf, struct ipmi_rs *rsp) +struct ipmi_rs *lan::ipmi_lan_recv_sol( struct ipmi_rs *rsp) { - rsp = lan::ipmi_lan_poll_recv(intf, rsp); + rsp = lan::ipmi_lan_poll_recv( rsp); - ack_sol_packet(intf, rsp); + ack_sol_packet( rsp); /* * Remembers the data sent, and alters the data to just * include the new stuff. */ - check_sol_packet_for_new_data(intf, rsp); + check_sol_packet_for_new_data( rsp); return rsp; } /* send a get device id command to keep session active */ -int lan::ipmi_lan_keepalive(ipmi_intf * intf) +int lan::ipmi_lan_keepalive() { struct ipmi_rs *rsp; struct ipmi_rq req; @@ -1592,17 +1593,17 @@ int lan::ipmi_lan_keepalive(ipmi_intf * intf) /* * IPMI Get Channel Authentication Capabilities Command */ -int lan::ipmi_get_auth_capabilities_cmd(ipmi_intf * intf) +int lan::ipmi_get_auth_capabilities_cmd() { struct ipmi_rs * rsp; struct ipmi_rq req; - struct ipmi_session * s = intf->session; + ipmi_session<lan> * s = intf->session; uint8_t msg_data[2]; msg_data[0] = IPMI_LAN_CHANNEL_E; msg_data[1] = s->privlvl; - - memset(&req, 0, sizeof(req)); + req.zero(); +// memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_APP; req.msg.cmd = 0x38; req.msg.data = msg_data; @@ -1699,18 +1700,18 @@ int lan::ipmi_get_auth_capabilities_cmd(ipmi_intf * intf) * IPMI Get Session Challenge Command * returns a temporary session ID and 16 byte challenge string */ -int lan::ipmi_get_session_challenge_cmd(ipmi_intf * intf) +int lan::ipmi_get_session_challenge_cmd() { struct ipmi_rs * rsp; struct ipmi_rq req; - struct ipmi_session * s = intf->session; + ipmi_session<lan> * s = intf->session; uint8_t msg_data[17]; memset(msg_data, 0, 17); msg_data[0] = s->authtype; memcpy(msg_data + 1, s->username, 16); - - memset(&req, 0, sizeof(req)); + req.zero(); +// memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_APP; req.msg.cmd = 0x39; req.msg.data = msg_data; @@ -1765,14 +1766,14 @@ int lan::ipmi_get_session_challenge_cmd(ipmi_intf * intf) /* * IPMI Activate Session Command */ -int lan::ipmi_activate_session_cmd(ipmi_intf * intf) +int lan::ipmi_activate_session_cmd() { struct ipmi_rs * rsp; struct ipmi_rq req; - struct ipmi_session * s = intf->session; + ipmi_session<lan> * s = intf->session; uint8_t msg_data[22]; - - memset(&req, 0, sizeof(req)); + req.zero(); +// memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_APP; req.msg.cmd = 0x3a; @@ -1780,7 +1781,7 @@ int lan::ipmi_activate_session_cmd(ipmi_intf * intf) msg_data[1] = s->privlvl; /* supermicro oem authentication hack */ - if (ipmi_oem_active(intf, "supermicro")) + if (oemO->ipmi_oem_active( "supermicro")) { uint8_t * special = auth->ipmi_auth_special(s); memcpy(s->authcode, special, 16); @@ -1881,7 +1882,7 @@ int lan::ipmi_activate_session_cmd(ipmi_intf * intf) /* * IPMI Set Session Privilege Level Command */ -int lan::ipmi_set_session_privlvl_cmd(ipmi_intf * intf) +int lan::ipmi_set_session_privlvl_cmd() { struct ipmi_rs * rsp; struct ipmi_rq req; @@ -1890,8 +1891,8 @@ int lan::ipmi_set_session_privlvl_cmd(ipmi_intf * intf) if (privlvl <= IPMI_SESSION_PRIV_USER) return 0; /* no need to set higher */ - - memset(&req, 0, sizeof(req)); + req.zero(); +// memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_APP; req.msg.cmd = 0x3b; req.msg.data = &privlvl; @@ -1924,7 +1925,7 @@ int lan::ipmi_set_session_privlvl_cmd(ipmi_intf * intf) return 0; } -int lan::ipmi_close_session_cmd(ipmi_intf * intf) +int lan::ipmi_close_session_cmd() { struct ipmi_rs * rsp; struct ipmi_rq req; @@ -1938,8 +1939,8 @@ int lan::ipmi_close_session_cmd(ipmi_intf * intf) bridge_possible = 0; /* Not a bridge message */ memcpy(&msg_data, &session_id, 4); - - memset(&req, 0, sizeof(req)); + req.zero(); +// memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_APP; req.msg.cmd = 0x3c; req.msg.data = msg_data; @@ -1989,7 +1990,7 @@ int lan::ipmi_close_session_cmd(ipmi_intf * intf) * 5. BMC returns response confirming session activation and * session ID for this session and initial inbound sequence. */ -int lan::ipmi_lan_activate_session(ipmi_intf * intf) +int lan::ipmi_lan_activate_session() { int rc; @@ -1997,9 +1998,9 @@ int lan::ipmi_lan_activate_session(ipmi_intf * intf) * Supermicro's IPMI LAN 1.5 cards don't tolerate pings. */ sessionsup_fail = 0; - if (!ipmi_oem_active(intf, "supermicro")) + if (!oemO->ipmi_oem_active( "supermicro")) { - int ist = ipmi_lan_ping(intf); + int ist = ipmi_lan_ping(); if (ist == 0) { sessionsup_fail = SessSup_PingFail; @@ -2010,10 +2011,10 @@ int lan::ipmi_lan_activate_session(ipmi_intf * intf) /* Some particular Intel boards need special help */ - if (ipmi_oem_active(intf, "intelwv2")) - lan::ipmi_lan_thump_first(intf); + if (oemO->ipmi_oem_active( "intelwv2")) + lan::ipmi_lan_thump_first(); - rc = ipmi_get_auth_capabilities_cmd(intf); + rc = ipmi_get_auth_capabilities_cmd(); if (rc < 0) { sessionsup_fail = SessSup_auth_capabilities_cmd; @@ -2021,14 +2022,14 @@ int lan::ipmi_lan_activate_session(ipmi_intf * intf) goto fail; } - rc = ipmi_get_session_challenge_cmd(intf); + rc = ipmi_get_session_challenge_cmd(); if (rc < 0) { lPrintf(LOG_DEBUG, "Error: ipmi_get_session_challenge_cmd failed"); goto fail; } - rc = ipmi_activate_session_cmd(intf); + rc = ipmi_activate_session_cmd(); if (rc < 0) { sessionsup_fail = SessSup_ActFail; @@ -2038,7 +2039,7 @@ int lan::ipmi_lan_activate_session(ipmi_intf * intf) intf->abort = 0; - rc = ipmi_set_session_privlvl_cmd(intf); + rc = ipmi_set_session_privlvl_cmd(); if (rc < 0) { sessionsup_fail = SessSup_PrivFail; @@ -2052,10 +2053,10 @@ int lan::ipmi_lan_activate_session(ipmi_intf * intf) return -1; } -void lan::ipmi_lan_close(ipmi_intf * intf) +void lan::ipmi_close() { if (intf->abort == 0) - ipmi_close_session_cmd(intf); + ipmi_close_session_cmd(); if (intf->fd >= 0) close(intf->fd); @@ -2067,10 +2068,10 @@ void lan::ipmi_lan_close(ipmi_intf * intf) intf = NULL; } -int lan::ipmi_lan_open(ipmi_intf * intf) +int lan::ipmi_open() { int rc; - struct ipmi_session *s; + ipmi_session<lan> *s; if (intf == NULL) return -1; @@ -2111,9 +2112,8 @@ int lan::ipmi_lan_open(ipmi_intf * intf) } intf->opened = 1; - /* try to open session */ - rc = ipmi_lan_activate_session(intf); + rc = ipmi_lan_activate_session(); if (rc < 0) { intf->ipmi_close(); @@ -2124,12 +2124,12 @@ int lan::ipmi_lan_open(ipmi_intf * intf) intf->manufacturer_id = intf->helper->ipmi_get_oem(intf); /* automatically detect interface request and response sizes */ - hpm2_detect_max_payload_size(intf); + hpm2_detect_max_payload_size<lan>(intf); return intf->fd; } -int lan::ipmi_lan_setup(ipmi_intf * intf) +int lan::ipmi_setup() { if (intf->session == 0) intf->session = new ipmi_session(intf); if (intf->session == NULL) @@ -2145,7 +2145,7 @@ int lan::ipmi_lan_setup(ipmi_intf * intf) return 0; } -void lan::ipmi_lan_set_max_rq_data_size(ipmi_intf * intf, uint16_t size) +void lan::ipmi_lan_set_max_rq_data_size( uint16_t size) { if (size + 7 > 0xFF) { @@ -2155,7 +2155,7 @@ void lan::ipmi_lan_set_max_rq_data_size(ipmi_intf * intf, uint16_t size) intf->max_request_data_size = size; } -void lan::ipmi_lan_set_max_rp_data_size(ipmi_intf * intf, uint16_t size) +void lan::ipmi_lan_set_max_rp_data_size( uint16_t size) { if (size + 8 > 0xFF) { diff --git a/Online/IPMI/src/NewLib/lan.h b/Online/IPMI/src/NewLib/lan.h index 335699706dda974fed0259ae437174bfefc66ae3..e78d7bc5eeb21a1ca37ef4d6fbf3775472c81bf8 100644 --- a/Online/IPMI/src/NewLib/lan.h +++ b/Online/IPMI/src/NewLib/lan.h @@ -26,88 +26,102 @@ #define IPMI_LAN_MAX_REQUEST_SIZE 38 /* 45 - 7 */ #define IPMI_LAN_MAX_RESPONSE_SIZE 34 /* 42 - 8 */ -//#include <string> +#include <string> +#include "ipmi_intf.h" +#include "ipmi_oem.h" +#include "auth.h" +#include "lanplus_crypt.h" //using namespace std; /* * LAN interface is required to support 45 byte request transactions and * 42 byte response transactions. */ -/*typedef*/ enum -{ - SessSup_PingFail =1, - SessSup_auth_capabilities_cmd, - SessSup_BadUserName, - SessSup_NoSlot, - SessSup_NoSlotUser, - SessSup_ActFail, - SessSup_PrivFail, - SessSup_NEXNode, -}; -class ipmi_intf; -class ipmi_auth; +//template <typename T> class ipmi_intf<T>; +//class ipmi_auth; class lan { +//using ipmi_Intf = ipmi_intf<lan>; public: #include "newnew.h" - struct ipmi_rq_entry * ipmi_req_entries; - struct ipmi_rq_entry * ipmi_req_entries_tail; + ipmi_rq_entry<lan> * ipmi_req_entries; + ipmi_rq_entry<lan> * ipmi_req_entries_tail; + ipmi_oem<lan> *oemO; + ipmi_intf<lan> *intf; uint8_t bridge_possible; char name[16];//: "lan" char desc[128];//("IPMI v1.5 LAN Interface"); - lan(); + LANPlusCrypt<lan> *Crypt; + lan(ipmi_intf<lan> *Intf) + { + this->intf = Intf; + strcpy(name, "lan"); + strcpy(desc, "IPMI v1.5 LAN Interface"); + ipmi_req_entries = 0; + ipmi_req_entries_tail = 0; + bridge_possible = 0; + auth = new ipmi_auth<lan>(); + sessionsup_fail = false; + oemO = new ipmi_oem<lan>(intf); + Crypt = new LANPlusCrypt<lan>(oemO); + + } ~lan(); - ipmi_auth *auth; + ipmi_auth<lan> *auth; int sessionsup_fail; int get_session_setup_code(){return sessionsup_fail;}; - struct ipmi_rq_entry *ipmi_req_add_entry( ipmi_intf * intf, struct ipmi_rq * req, uint8_t req_seq); - struct ipmi_rq_entry *ipmi_req_lookup_entry(uint8_t seq, uint8_t cmd); + ipmi_rq_entry<lan> *ipmi_req_add_entry( struct ipmi_rq * req, uint8_t req_seq); + ipmi_rq_entry<lan> *ipmi_req_lookup_entry(uint8_t seq, uint8_t cmd); void ipmi_req_remove_entry(uint8_t seq, uint8_t cmd); void ipmi_req_clear_entries(void); int get_random(void *data, int len); - int ipmi_lan_send_packet( ipmi_intf * intf, uint8_t * data, + int ipmi_lan_send_packet( uint8_t * data, int data_len); - struct ipmi_rs * ipmi_lan_recv_packet( ipmi_intf * intf,struct ipmi_rs *); - int ipmi_handle_pong( ipmi_intf * intf, struct ipmi_rs * rsp); - int ipmi_lan_ping( ipmi_intf * intf); - void ipmi_lan_thump_first( ipmi_intf * intf); - void ipmi_lan_thump( ipmi_intf * intf); - struct ipmi_rs * ipmi_lan_poll_recv( ipmi_intf * intf,struct ipmi_rs *); - struct ipmi_rq_entry * ipmi_lan_build_cmd( ipmi_intf * intf, - struct ipmi_rq * req, int isRetry); - struct ipmi_rs * ipmi_lan_send_cmd( ipmi_intf * intf, - struct ipmi_rq * req,struct ipmi_rs *); - uint8_t * ipmi_lan_build_rsp( ipmi_intf * intf, struct ipmi_rs * rsp, + struct ipmi_rs * ipmi_lan_recv_packet( struct ipmi_rs *); + int ipmi_handle_pong( struct ipmi_rs * rsp); + int ipmi_lan_ping( ); + void ipmi_lan_thump_first(); + void ipmi_lan_thump( ); + struct ipmi_rs * ipmi_lan_poll_recv( struct ipmi_rs *); + ipmi_rq_entry<lan> * ipmi_lan_build_cmd( struct ipmi_rq * req, int isRetry); + struct ipmi_rs * ipmi_send_cmd( struct ipmi_rq * req,struct ipmi_rs *); + uint8_t * ipmi_lan_build_rsp( struct ipmi_rs * rsp, int * llen); - int ipmi_lan_send_rsp( ipmi_intf * intf, struct ipmi_rs * rsp); - uint8_t * ipmi_lan_build_sol_msg( ipmi_intf * intf, - struct ipmi_v2_payload * payload, int * llen); + int ipmi_lan_send_rsp( struct ipmi_rs * rsp); + uint8_t * ipmi_lan_build_sol_msg( struct ipmi_v2_payload * payload, int * llen); int is_sol_packet(struct ipmi_rs * rsp); int sol_response_acks_packet( ipmi_rs * rsp, struct ipmi_v2_payload * payload); - struct ipmi_rs * ipmi_lan_send_sol_payload( ipmi_intf * intf, - struct ipmi_v2_payload * payload,struct ipmi_rs *); + struct ipmi_rs * ipmi_lan_send_sol_payload( struct ipmi_v2_payload * payload,struct ipmi_rs *); int is_sol_partial_ack( ipmi_v2_payload * v2_payload, struct ipmi_rs * rsp); - void set_sol_packet_sequence_number( ipmi_intf * intf, - struct ipmi_v2_payload * v2_payload); - struct ipmi_rs * ipmi_lan_send_sol( ipmi_intf * intf, - struct ipmi_v2_payload * v2_payload,struct ipmi_rs *); - int check_sol_packet_for_new_data( ipmi_intf * intf, - struct ipmi_rs *rsp); - void ack_sol_packet( ipmi_intf * intf, struct ipmi_rs * rsp); - struct ipmi_rs * ipmi_lan_recv_sol( ipmi_intf * intf,struct ipmi_rs *); - int ipmi_lan_keepalive( ipmi_intf * intf); - int ipmi_get_auth_capabilities_cmd( ipmi_intf * intf); - int ipmi_get_session_challenge_cmd( ipmi_intf * intf); - int ipmi_activate_session_cmd( ipmi_intf * intf); - int ipmi_set_session_privlvl_cmd( ipmi_intf * intf); - int ipmi_close_session_cmd( ipmi_intf * intf); - int ipmi_lan_activate_session( ipmi_intf * intf); - void ipmi_lan_close( ipmi_intf * intf); - int ipmi_lan_open( ipmi_intf * intf); - int ipmi_lan_setup( ipmi_intf * intf); - void ipmi_lan_set_max_rq_data_size( ipmi_intf * intf, uint16_t size); - void ipmi_lan_set_max_rp_data_size( ipmi_intf * intf, uint16_t size); + void set_sol_packet_sequence_number( struct ipmi_v2_payload * v2_payload); + struct ipmi_rs * ipmi_lan_send_sol( struct ipmi_v2_payload * v2_payload,struct ipmi_rs *); + int check_sol_packet_for_new_data( struct ipmi_rs *rsp); + void ack_sol_packet( struct ipmi_rs * rsp); + struct ipmi_rs * ipmi_lan_recv_sol( struct ipmi_rs *); + int ipmi_lan_keepalive( ); + int ipmi_get_auth_capabilities_cmd( ); + int ipmi_get_session_challenge_cmd( ); + int ipmi_activate_session_cmd( ); + int ipmi_set_session_privlvl_cmd( ); + int ipmi_close_session_cmd( ); + int ipmi_lan_activate_session( ); + void ipmi_close( ); + int ipmi_open( ); + int ipmi_setup( ); + void ipmi_lan_set_max_rq_data_size( uint16_t size); + void ipmi_lan_set_max_rp_data_size( uint16_t size); + int setup(){return ipmi_setup();}; +// int open(){return ipmi_lan_open();}; +// void ipmi_close(){return ipmi_lan_close();}; + struct ipmi_rs rs; + struct ipmi_rs *sendrecv(struct ipmi_rq * req){return ipmi_send_cmd(req,&rs);}; + int sendrsp(struct ipmi_rs *rsp){return ipmi_lan_send_rsp(rsp);}; + struct ipmi_rs *recv_sol(){return ipmi_lan_recv_sol(&rs);}; + struct ipmi_rs *send_sol(struct ipmi_v2_payload * payload){return ipmi_lan_send_sol(payload,&rs);}; + int keepalive(){return ipmi_lan_keepalive();}; + void set_max_request_data_size(uint16_t size){return ipmi_lan_set_max_rq_data_size(size);}; + void set_max_response_data_size(uint16_t size){return ipmi_lan_set_max_rp_data_size(size);}; }; #endif /* ONLINE_IPMI_SRC_NEWLIB_LAN_H_ */ diff --git a/Online/IPMI/src/NewLib/lanplus_crypt.cpp b/Online/IPMI/src/NewLib/lanplus_crypt.cpp new file mode 100755 index 0000000000000000000000000000000000000000..5a365d00f41fa748795002de9f61da808631341d --- /dev/null +++ b/Online/IPMI/src/NewLib/lanplus_crypt.cpp @@ -0,0 +1,1060 @@ +/* + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. + * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. + * SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE + * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING + * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL + * SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, + * OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR + * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF + * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, + * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + */ + +#include <assert.h> +#include <string.h> +#include "log.h" +#if defined(HAVE_CONFIG_H) +# include "config.h" +#endif +#include "bswap.h" +#include "LANPlus.h" +#include "ipmi_intf.h" +#include "lanplus_crypt.h" +#include "lanplus_crypt_impl.h" +#include "ipmi_constants.h" +#include "log.h" +#include "helper.h" +#include "ipmi_session.h" +#include "ipmi_oem.h" + +int verbose; + +/* + * rakp2_hmac_matches + * + * param session holds all the state data that we need to generate the hmac + * param hmac is the HMAC sent by the BMC in the RAKP 2 message + * + * The HMAC was generated [per RFC2404] from : + * + * SIDm - Remote console session ID + * SIDc - BMC session ID + * Rm - Remote console random number + * Rc - BMC random number + * GUIDc - BMC guid + * ROLEm - Requested privilege level (entire byte) + * ULENGTHm - Username length + * <UNAMEm> - Username (absent for null user names) + * + * generated by using Kuid. I am aware that the subscripts on the values + * look backwards, but that's the way they are written in the specification. + * + * If the authentication algorithm is IPMI_AUTH_RAKP_NONE, we return success. + * + * return 0 on success (the authcode matches) + * 1 on failure (the authcode does not match) + */ +static ipmi_helper<LANPlus> h; +template <> int LANPlusCrypt<LANPlus>::rakp2_hmac_matches(ipmi_session<LANPlus> * session, + const uint8_t * bmc_mac, ipmi_intf<LANPlus> * intf) +{ + uint8_t * buffer; + int bufferLength, i; + uint8_t mac[IPMI_MAX_MD_SIZE]; + uint32_t macLength; + + uint32_t SIDm_lsbf, SIDc_lsbf; + + if (session->v2_data.auth_alg == IPMI_AUTH_RAKP_NONE) + return 1; + + /* We don't yet support other algorithms */ + assert((session->v2_data.auth_alg == IPMI_AUTH_RAKP_HMAC_SHA1) + || (session->v2_data.auth_alg == IPMI_AUTH_RAKP_HMAC_MD5) +#ifdef HAVE_CRYPTO_SHA256 + || (session->v2_data.auth_alg == IPMI_AUTH_RAKP_HMAC_SHA256) +#endif /* HAVE_CRYPTO_SHA256 */ + ); + + + bufferLength = + 4 + /* SIDm */ + 4 + /* SIDc */ + 16 + /* Rm */ + 16 + /* Rc */ + 16 + /* GUIDc */ + 1 + /* ROLEm */ + 1 + /* ULENGTHm */ + strlen((const char *)intf->session->username); /* optional */ + + buffer = (uint8_t*)malloc(bufferLength); + if (buffer == NULL) { + lPrintf(LOG_ERR, "ipmiool: malloc failure"); + return 1; + } + + /* + * Fill the buffer. I'm assuming that we're using the LSBF representation of the + * multibyte numbers in use. + */ + + /* SIDm */ + SIDm_lsbf = session->v2_data.console_id; + #if WORDS_BIGENDIAN + SIDm_lsbf = BSWAP_32(SIDm_lsbf); + #endif + + memcpy(buffer, &SIDm_lsbf, 4); + + /* SIDc */ + SIDc_lsbf = session->v2_data.bmc_id; + #if WORDS_BIGENDIAN + SIDc_lsbf = BSWAP_32(SIDc_lsbf); + #endif + memcpy(buffer + 4, &SIDc_lsbf, 4); + + /* Rm */ + #if WORDS_BIGENDIAN + for (i = 0; i < 16; ++i) + buffer[8 + i] = session->v2_data.console_rand[16 - 1 - i]; + #else + for (i = 0; i < 16; ++i) + buffer[8 + i] = session->v2_data.console_rand[i]; + #endif + + /* Rc */ + #if WORDS_BIGENDIAN + for (i = 0; i < 16; ++i) + buffer[24 + i] = session->v2_data.bmc_rand[16 - 1 - i]; + #else + for (i = 0; i < 16; ++i) + buffer[24 + i] = session->v2_data.bmc_rand[i]; + #endif + + /* GUIDc */ + #if WORDS_BIGENDIAN + for (i = 0; i < 16; ++i) + buffer[40 + i] = session->v2_data.bmc_guid[16 - 1 - i]; + #else + for (i = 0; i < 16; ++i) + buffer[40 + i] = session->v2_data.bmc_guid[i]; + #endif + + /* ROLEm */ + buffer[56] = session->v2_data.requested_role; + + if (oemO->ipmi_oem_active( "i82571spt")) { + /* + * The HMAC calculation code in the Intel 82571 GbE + * skips this bit! Looks like a GbE bug, but we need + * to work around it here anyway... + */ + buffer[56] &= ~0x10; + } + + /* ULENGTHm */ + buffer[57] = strlen((const char *)intf->session->username); + + /* UserName [optional] */ + for (i = 0; i < buffer[57]; ++i) + buffer[58 + i] = intf->session->username[i]; + + if (verbose > 2) + { + h.printbuf((const uint8_t *)buffer, bufferLength, ">> rakp2 mac input buffer"); + h.printbuf((const uint8_t *)session->authcode, IPMI_AUTHCODE_BUFFER_SIZE, ">> rakp2 mac key"); + } + + /* + * The buffer is complete. Let's hash. + */ + HMAC(session->v2_data.auth_alg, + session->authcode, + IPMI_AUTHCODE_BUFFER_SIZE, + buffer, + bufferLength, + mac, + &macLength); + + free(buffer); + buffer = NULL; + + + if (verbose > 2) + { + h.printbuf(mac, macLength, ">> rakp2 mac as computed by the remote console"); + } + + return (memcmp(bmc_mac, mac, macLength) == 0); +} + + +/* + * rakp4_hmac_matches + * + * param session holds all the state data that we need to generate the hmac + * param hmac is the HMAC sent by the BMC in the RAKP 4 message + * + * The HMAC was generated [per RFC2404] from : + * + * Rm - Remote console random number + * SIDc - BMC session ID + * GUIDc - BMC guid + * + * generated by using SIK (the session integrity key). I am aware that the + * subscripts on the values look backwards, but that's the way they are + * written in the specification. + * + * If the authentication algorithm is IPMI_AUTH_RAKP_NONE, we return success. + * + * return 1 on success (the authcode matches) + * 0 on failure (the authcode does not match) + * + */ +template <> int LANPlusCrypt<LANPlus>::rakp4_hmac_matches(ipmi_session<LANPlus> * session, + const uint8_t * bmc_mac, + ipmi_intf<LANPlus> * ) +{ + uint8_t * buffer; + int bufferLength, i; + uint8_t mac[IPMI_MAX_MD_SIZE]; + uint32_t macLength; + uint32_t cmpLength=0; + uint32_t SIDc_lsbf; + + if (oemO->ipmi_oem_active( "intelplus")){ + /* Intel BMC responds with the integrity Algorithm in RAKP4 */ + if (session->v2_data.integrity_alg == IPMI_INTEGRITY_NONE) + return 1; + + /* We don't yet support other algorithms */ + assert((session->v2_data.integrity_alg == IPMI_INTEGRITY_HMAC_SHA1_96) + || (session->v2_data.integrity_alg == IPMI_INTEGRITY_HMAC_MD5_128)); + } else { + if (session->v2_data.auth_alg == IPMI_AUTH_RAKP_NONE) + return 1; + + /* We don't yet support other algorithms */ + assert((session->v2_data.auth_alg == IPMI_AUTH_RAKP_HMAC_SHA1) + || (session->v2_data.auth_alg == IPMI_AUTH_RAKP_HMAC_MD5) +#ifdef HAVE_CRYPTO_SHA256 + || (session->v2_data.auth_alg == IPMI_AUTH_RAKP_HMAC_SHA256) +#endif /* HAVE_CRYPTO_SHA256 */ + ); + } + + bufferLength = + 16 + /* Rm */ + 4 + /* SIDc */ + 16; /* GUIDc */ + + buffer = (uint8_t *)malloc(bufferLength); + if (buffer == NULL) { + lPrintf(LOG_ERR, "ipmitool: malloc failure"); + return 1; + } + + /* + * Fill the buffer. I'm assuming that we're using the LSBF representation of the + * multibyte numbers in use. + */ + + /* Rm */ + #if WORDS_BIGENDIAN + for (i = 0; i < 16; ++i) + buffer[i] = session->v2_data.console_rand[16 - 1 - i]; + #else + for (i = 0; i < 16; ++i) + buffer[i] = session->v2_data.console_rand[i]; + #endif + + + /* SIDc */ + SIDc_lsbf = session->v2_data.bmc_id; + #if WORDS_BIGENDIAN + SIDc_lsbf = BSWAP_32(SIDc_lsbf); + #endif + memcpy(buffer + 16, &SIDc_lsbf, 4); + + + /* GUIDc */ + #if WORDS_BIGENDIAN + for (i = 0; i < 16; ++i) + buffer[i + 20] = session->v2_data.bmc_guid[16 - 1 - i]; + #else + for (i = 0; i < 16; ++i) + buffer[i + 20] = session->v2_data.bmc_guid[i]; + #endif + + + if (verbose > 2) + { + h.printbuf((const uint8_t *)buffer, bufferLength, ">> rakp4 mac input buffer"); + h.printbuf(session->v2_data.sik, session->v2_data.sik_len, + ">> rakp4 mac key (sik)"); + } + + + /* + * The buffer is complete. Let's hash. + */ + HMAC((oemO->ipmi_oem_active( "intelplus")) + ? session->v2_data.integrity_alg + : session->v2_data.auth_alg , + session->v2_data.sik, + session->v2_data.sik_len, + buffer, + bufferLength, + mac, + &macLength); + + if (verbose > 2) + { + h.printbuf(bmc_mac, macLength, ">> rakp4 mac as computed by the BMC"); + h.printbuf(mac, macLength, ">> rakp4 mac as computed by the remote console"); + } + + if (oemO->ipmi_oem_active( "intelplus")) { + /* Intel BMC responds with the integrity Algorithm in RAKP4 */ + switch(session->v2_data.integrity_alg) { + case IPMI_INTEGRITY_HMAC_SHA1_96: + assert(macLength == IPMI_SHA_DIGEST_LENGTH); + cmpLength = IPMI_SHA1_AUTHCODE_SIZE; + break; + case IPMI_INTEGRITY_HMAC_MD5_128: + assert(macLength == IPMI_MD5_DIGEST_LENGTH); + cmpLength = IPMI_HMAC_MD5_AUTHCODE_SIZE; + break; + default: + assert(0); + break; + } + } else { + /* We don't yet support other algorithms */ + switch(session->v2_data.auth_alg) { + case IPMI_AUTH_RAKP_HMAC_SHA1: + assert(macLength == IPMI_SHA_DIGEST_LENGTH); + cmpLength = IPMI_SHA1_AUTHCODE_SIZE; + break; + case IPMI_AUTH_RAKP_HMAC_MD5: + assert(macLength == IPMI_MD5_DIGEST_LENGTH); + cmpLength = IPMI_HMAC_MD5_AUTHCODE_SIZE; + break; +#ifdef HAVE_CRYPTO_SHA256 + case IPMI_AUTH_RAKP_HMAC_SHA256: + assert(macLength == IPMI_SHA256_DIGEST_LENGTH); + cmpLength = IPMI_HMAC_SHA256_AUTHCODE_SIZE; + break; +#endif /* HAVE_CRYPTO_SHA256 */ + default: + assert(0); + break; + } + } + + free(buffer); + buffer = NULL; + assert(macLength >= cmpLength); + return (memcmp(bmc_mac, mac, cmpLength) == 0); +} + + + +/* + * generate_rakp3_auth_code + * + * This auth code is an HMAC generated with : + * + * Rc - BMC random number + * SIDm - Console session ID + * ROLEm - Requested privilege level (entire byte) + * ULENGTHm - Username length + * <USERNAME> - Usename (absent for null usernames) + * + * The key used to generated the MAC is Kuid + * + * I am aware that the subscripts look backwards, but that is the way they are + * written in the spec. + * + * param output_buffer [out] will hold the generated MAC + * param session [in] holds all the state data we need to generate the auth code + * param mac_length [out] will be set to the length of the auth code + * + * returns 0 on success + * 1 on failure + */ +template <> int LANPlusCrypt<LANPlus>::generate_rakp3_authcode(uint8_t * output_buffer, + ipmi_session<LANPlus> * session, + uint32_t * mac_length, + ipmi_intf<LANPlus> * intf) +{ + int ret = 0; + int input_buffer_length, i; + uint8_t * input_buffer; + uint32_t SIDm_lsbf; + + + if (session->v2_data.auth_alg == IPMI_AUTH_RAKP_NONE) + { + *mac_length = 0; + return 0; + } + + /* We don't yet support other algorithms */ + assert((session->v2_data.auth_alg == IPMI_AUTH_RAKP_HMAC_SHA1) + || (session->v2_data.auth_alg == IPMI_AUTH_RAKP_HMAC_MD5) +#ifdef HAVE_CRYPTO_SHA256 + || (session->v2_data.auth_alg == IPMI_AUTH_RAKP_HMAC_SHA256) +#endif /* HAVE_CRYPTO_SHA256 */ + ); + + input_buffer_length = + 16 + /* Rc */ + 4 + /* SIDm */ + 1 + /* ROLEm */ + 1 + /* ULENGTHm */ + strlen((const char *)intf->session->username); + + input_buffer = (uint8_t*)malloc(input_buffer_length); + if (input_buffer == NULL) { + lPrintf(LOG_ERR, "ipmitool: malloc failure"); + return 1; + } + + /* + * Fill the buffer. I'm assuming that we're using the LSBF representation of the + * multibyte numbers in use. + */ + + /* Rc */ + #if WORDS_BIGENDIAN + for (i = 0; i < 16; ++i) + input_buffer[i] = session->v2_data.bmc_rand[16 - 1 - i]; + #else + for (i = 0; i < 16; ++i) + input_buffer[i] = session->v2_data.bmc_rand[i]; + #endif + + /* SIDm */ + SIDm_lsbf = session->v2_data.console_id; + #if WORDS_BIGENDIAN + SIDm_lsbf = BSWAP_32(SIDm_lsbf); + #endif + memcpy(input_buffer + 16, &SIDm_lsbf, 4); + + /* ROLEm */ + if (oemO->ipmi_oem_active( "intelplus") || oemO->ipmi_oem_active( "i82571spt")) + input_buffer[20] = intf->session->privlvl; + else + input_buffer[20] = session->v2_data.requested_role; + + /* ULENGTHm */ + input_buffer[21] = strlen((const char *)intf->session->username); + + /* USERNAME */ + for (i = 0; i < input_buffer[21]; ++i) + input_buffer[22 + i] = intf->session->username[i]; + + if (verbose > 2) + { + h.printbuf((const uint8_t *)input_buffer, input_buffer_length, ">> rakp3 mac input buffer"); + h.printbuf((const uint8_t *)session->authcode, IPMI_AUTHCODE_BUFFER_SIZE, ">> rakp3 mac key"); + } + + HMAC(session->v2_data.auth_alg, + session->authcode, + IPMI_AUTHCODE_BUFFER_SIZE, + input_buffer, + input_buffer_length, + output_buffer, + mac_length); + + if (verbose > 2) + h.printbuf((const uint8_t *)output_buffer, *mac_length, "generated rakp3 mac"); + + + free(input_buffer); + input_buffer = NULL; + + return ret; +} + + + +/* + * generate_sik + * + * Generate the session integrity key (SIK) used for integrity checking + * during the IPMI v2 / RMCP+ session + * + * This session integrity key is a HMAC generated with : + * + * Rm - Console generated random number + * Rc - BMC generated random number + * ROLEm - Requested privilege level (entire byte) + * ULENGTHm - Username length + * <USERNAME> - Usename (absent for null usernames) + * + * The key used to generated the SIK is Kg if Kg is not null (two-key logins are + * enabled). Otherwise Kuid (the user authcode) is used as the key to genereate + * the SIK. + * + * I am aware that the subscripts look backwards, but that is the way they are + * written in the spec. + * + * param session [in/out] contains our input and output fields. + * + * returns 0 on success + * 1 on failure + */ +template <> int LANPlusCrypt<LANPlus>::generate_sik( ipmi_session<LANPlus> * session, ipmi_intf<LANPlus> * intf) +{ + uint8_t * input_buffer; + int input_buffer_length, i; + uint8_t * input_key; + uint32_t mac_length; + + + memset(session->v2_data.sik, 0, sizeof(session->v2_data.sik)); + session->v2_data.sik_len = 0; + + if (session->v2_data.auth_alg == IPMI_AUTH_RAKP_NONE) + return 0; + + /* We don't yet support other algorithms */ + assert((session->v2_data.auth_alg == IPMI_AUTH_RAKP_HMAC_SHA1) + || (session->v2_data.auth_alg == IPMI_AUTH_RAKP_HMAC_MD5) +#ifdef HAVE_CRYPTO_SHA256 + || (session->v2_data.auth_alg == IPMI_AUTH_RAKP_HMAC_SHA256) +#endif /* HAVE_CRYPTO_SHA256 */ + ); + + input_buffer_length = + 16 + /* Rm */ + 16 + /* Rc */ + 1 + /* ROLEm */ + 1 + /* ULENGTHm */ + strlen((const char *)intf->session->username); + + input_buffer = (uint8_t *)malloc(input_buffer_length); + if (input_buffer == NULL) { + lPrintf(LOG_ERR, "ipmitool: malloc failure"); + return 1; + } + + /* + * Fill the buffer. I'm assuming that we're using the LSBF representation of the + * multibyte numbers in use. + */ + + /* Rm */ + #if WORDS_BIGENDIAN + for (i = 0; i < 16; ++i) + input_buffer[i] = session->v2_data.console_rand[16 - 1 - i]; + #else + for (i = 0; i < 16; ++i) + input_buffer[i] = session->v2_data.console_rand[i]; + #endif + + + /* Rc */ + #if WORDS_BIGENDIAN + for (i = 0; i < 16; ++i) + input_buffer[16 + i] = session->v2_data.bmc_rand[16 - 1 - i]; + #else + for (i = 0; i < 16; ++i) + input_buffer[16 + i] = session->v2_data.bmc_rand[i]; + #endif + + /* ROLEm */ + input_buffer[32] = session->v2_data.requested_role; + + if (oemO->ipmi_oem_active( "i82571spt")) { + /* + * The HMAC calculation code in the Intel 82571 GbE + * skips this bit! Looks like a GbE bug, but we need + * to work around it here anyway... + */ + input_buffer[32] &= ~0x10; + } + + /* ULENGTHm */ + input_buffer[33] = strlen((const char *)intf->session->username); + + /* USERNAME */ + for (i = 0; i < input_buffer[33]; ++i) + input_buffer[34 + i] = intf->session->username[i]; + + if (intf->session->kg[0]) + { + /* We will be hashing with Kg */ + /* + * Section 13.31 of the IPMI v2 spec describes the SIK creation + * using Kg. It specifies that Kg should not be truncated. + * Kg is set in ipmi_intf. + */ + input_key = intf->session->kg; + } + else + { + /* We will be hashing with Kuid */ + input_key = session->authcode; + } + + + if (verbose >= 2) + h.printbuf((const uint8_t *)input_buffer, input_buffer_length, "session integrity key input"); + + HMAC(session->v2_data.auth_alg, + input_key, + IPMI_AUTHCODE_BUFFER_SIZE, + input_buffer, + input_buffer_length, + session->v2_data.sik, + &mac_length); + + free(input_buffer); + input_buffer = NULL; + switch (session->v2_data.auth_alg) { + case IPMI_AUTH_RAKP_HMAC_SHA1: + assert(mac_length == IPMI_SHA_DIGEST_LENGTH); + break; + case IPMI_AUTH_RAKP_HMAC_MD5: + assert(mac_length == IPMI_MD5_DIGEST_LENGTH); + break; +#ifdef HAVE_CRYPTO_SHA256 + case IPMI_AUTH_RAKP_HMAC_SHA256: + assert(mac_length == IPMI_SHA256_DIGEST_LENGTH); + break; +#endif /* HAVE_CRYPTO_SHA256 */ + default: + assert(0); + break; + } + + session->v2_data.sik_len = mac_length; + + /* + * The key MAC generated is 20 bytes, but we will only be using the first + * 12 for SHA1 96 + */ + if (verbose >= 2) { + h.printbuf(session->v2_data.sik, session->v2_data.sik_len, + "Generated session integrity key"); + } + return 0; +} + + + +/* + * generate_k1 + * + * Generate K1, the key presumably used to generate integrity authcodes + * + * We use the authentication algorithm to generated the HMAC, using + * the session integrity key (SIK) as our key. + * + * param session [in/out]. + * + * returns 0 on success + * 1 on failure + */ +template <> int LANPlusCrypt<LANPlus>::generate_k1( ipmi_session<LANPlus> * session) +{ + uint32_t mac_length; + + uint8_t CONST_1[] = + {0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}; + + if (session->v2_data.auth_alg == IPMI_AUTH_RAKP_NONE) + memcpy(session->v2_data.k1, CONST_1, 20); + else + { + HMAC(session->v2_data.auth_alg, + session->v2_data.sik, + session->v2_data.sik_len, /* SIK length */ + CONST_1, + 20, + session->v2_data.k1, + &mac_length); + switch (session->v2_data.auth_alg) { + case IPMI_AUTH_RAKP_HMAC_SHA1: + assert(mac_length == IPMI_SHA_DIGEST_LENGTH); + break; + case IPMI_AUTH_RAKP_HMAC_MD5: + assert(mac_length == IPMI_MD5_DIGEST_LENGTH); + break; +#ifdef HAVE_CRYPTO_SHA256 + case IPMI_AUTH_RAKP_HMAC_SHA256: + assert(mac_length == IPMI_SHA256_DIGEST_LENGTH); + break; +#endif /* HAVE_CRYPTO_SHA256 */ + default: + assert(0); + break; + } + session->v2_data.k1_len = mac_length; + } + + if (verbose >= 2) + h.printbuf(session->v2_data.k1, session->v2_data.k1_len, "Generated K1"); + + return 0; +} + + + +/* + * generate_k2 + * + * Generate K2, the key used for RMCP+ AES encryption. + * + * We use the authentication algorithm to generated the HMAC, using + * the session integrity key (SIK) as our key. + * + * param session [in/out]. + * + * returns 0 on success + * 1 on failure + */ +template <> int LANPlusCrypt<LANPlus>::generate_k2( ipmi_session<LANPlus> * session) +{ + uint32_t mac_length; + + uint8_t CONST_2[] = + {0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}; + + if (session->v2_data.auth_alg == IPMI_AUTH_RAKP_NONE) + memcpy(session->v2_data.k2, CONST_2, 20); + else + { + HMAC(session->v2_data.auth_alg, + session->v2_data.sik, + session->v2_data.sik_len, /* SIK length */ + CONST_2, + 20, + session->v2_data.k2, + &mac_length); + switch (session->v2_data.auth_alg) { + case IPMI_AUTH_RAKP_HMAC_SHA1: + assert(mac_length == IPMI_SHA_DIGEST_LENGTH); + break; + case IPMI_AUTH_RAKP_HMAC_MD5: + assert(mac_length == IPMI_MD5_DIGEST_LENGTH); + break; +#ifdef HAVE_CRYPTO_SHA256 + case IPMI_AUTH_RAKP_HMAC_SHA256: + assert(mac_length == IPMI_SHA256_DIGEST_LENGTH); + break; +#endif /* HAVE_CRYPTO_SHA256 */ + default: + assert(0); + break; + } + session->v2_data.k2_len = mac_length; + } + + if (verbose >= 2) + h.printbuf(session->v2_data.k2, session->v2_data.k2_len, "Generated K2"); + + return 0; +} + + + +/* + * encrypt_payload + * + * Perform the appropriate encryption on the input data. Output the encrypted + * data to output, including the required confidentiality header and trailer. + * If the crypt_alg is IPMI_CRYPT_NONE, simply copy the input to the output and + * set bytes_written to input_length. + * + * param crypt_alg specifies the encryption algorithm (from table 13-19 of the + * IPMI v2 spec) + * param key is the used as input to the encryption algorithmf + * param input is the input data to be encrypted + * param input_length is the length of the input data to be encrypted + * param output is the cipher text generated by the encryption process + * param bytes_written is the number of bytes written during the encryption + * process + * + * returns 0 on success + * 1 on failure + */ +template <> int LANPlusCrypt<LANPlus>::encrypt_payload(uint8_t crypt_alg, + const uint8_t * key, const uint8_t * input, + uint32_t input_length, uint8_t * output, + uint16_t * bytes_written) +{ + uint8_t * padded_input; + uint32_t mod, i, bytes_encrypted; + uint8_t pad_length = 0; + + if (crypt_alg == IPMI_CRYPT_NONE) + { + /* Just copy the input to the output */ + *bytes_written = input_length; + return 0; + } + + /* Currently, we only support AES */ + assert(crypt_alg == IPMI_CRYPT_AES_CBC_128); + assert(input_length <= IPMI_MAX_PAYLOAD_SIZE); + + + /* + * The input to the AES encryption algorithm has to be a multiple of the + * block size (16 bytes). The extra byte we are adding is the pad length + * byte. + */ + mod = (input_length + 1) % IPMI_CRYPT_AES_CBC_128_BLOCK_SIZE; + if (mod) + pad_length = IPMI_CRYPT_AES_CBC_128_BLOCK_SIZE - mod; + + padded_input = (uint8_t*)malloc(input_length + pad_length + 1); + if (padded_input == NULL) { + lPrintf(LOG_ERR, "ipmitool: malloc failure"); + return 1; + } + memcpy(padded_input, input, input_length); + + /* add the pad */ + for (i = 0; i < pad_length; ++i) + padded_input[input_length + i] = i + 1; + + /* add the pad length */ + padded_input[input_length + pad_length] = pad_length; + + /* Generate an initialization vector, IV, for the encryption process */ + if (lanplus_rand(output, IPMI_CRYPT_AES_CBC_128_BLOCK_SIZE)) + { + lPrintf(LOG_ERR, "lanplus_encrypt_payload: Error generating IV"); + if (padded_input != NULL) { + free(padded_input); + padded_input = NULL; + } + return 1; + } + + if (verbose > 2) + h.printbuf(output, IPMI_CRYPT_AES_CBC_128_BLOCK_SIZE, ">> Initialization vector"); + + + + encrypt_aes_cbc_128(output, /* IV */ + key, /* K2 */ + padded_input, /* Data to encrypt */ + input_length + pad_length + 1, /* Input length */ + output + IPMI_CRYPT_AES_CBC_128_BLOCK_SIZE, /* output */ + &bytes_encrypted); /* bytes written */ + + *bytes_written = + IPMI_CRYPT_AES_CBC_128_BLOCK_SIZE + /* IV */ + bytes_encrypted; + + free(padded_input); + padded_input = NULL; + + return 0; +} + + + +/* + * has_valid_auth_code + * + * Determine whether the packets authcode field is valid for packet. + * + * We always return success if any of the following are true. + * - this is not an IPMIv2 packet + * - the session is not yet active + * - the packet specifies that it is not authenticated + * - the integrity algorithm agreed upon during session creation is "none" + *strlen(name) + * The authcode is computed using the specified integrity algorithm starting + * with the AuthType / Format field, and ending with the field immediately + * preceeding the authcode itself. + * + * The key key used to generate the authcode MAC is K1. + * + * param rs holds the response structure. + * param session holds our session state, including our chosen algorithm, key, etc. + * + * returns 1 on success (authcode is valid) + * 0 on failure (autchode integrity check failed) + */ +template <> int LANPlusCrypt<LANPlus>::has_valid_auth_code( ipmi_rs * rs, ipmi_session<LANPlus> * session) +{ + uint8_t * bmc_authcode; + uint8_t generated_authcode[IPMI_MAX_MAC_SIZE]; + uint32_t generated_authcode_length=0; + uint32_t authcode_length=0; + + + if ((rs->session.authtype != IPMI_SESSION_AUTHTYPE_RMCP_PLUS) || + (session->v2_data.session_state != LANPLUS_STATE_ACTIVE) || + (! rs->session.bAuthenticated) || + (session->v2_data.integrity_alg == IPMI_INTEGRITY_NONE)) + return 1; + + switch (session->v2_data.integrity_alg) { + case IPMI_INTEGRITY_HMAC_SHA1_96: + authcode_length = IPMI_SHA1_AUTHCODE_SIZE; + break; + case IPMI_INTEGRITY_HMAC_MD5_128: + authcode_length = IPMI_HMAC_MD5_AUTHCODE_SIZE; + break; +#ifdef HAVE_CRYPTO_SHA256 + case IPMI_INTEGRITY_HMAC_SHA256_128: + authcode_length = IPMI_HMAC_SHA256_AUTHCODE_SIZE; + break; +#endif /* HAVE_CRYPTO_SHA256 */ + /* Unsupported */ + default: + assert(0); + break; + } + + /* + * For SHA1-96, the authcode will be the last 12 bytes in the packet + * For SHA256-128 or MD5-128, the authcode will be the last 16 bytes in the packet + */ + bmc_authcode = rs->data + (rs->data_len - authcode_length); + + HMAC(session->v2_data.integrity_alg, + session->v2_data.k1, + session->v2_data.k1_len, + rs->data + IPMI_LANPLUS_OFFSET_AUTHTYPE, + rs->data_len - IPMI_LANPLUS_OFFSET_AUTHTYPE - authcode_length, + generated_authcode, + &generated_authcode_length); + + if (verbose > 3) + { + lPrintf(LOG_DEBUG+2, "Validating authcode"); + h.printbuf(session->v2_data.k1, session->v2_data.k1_len, "K1"); + h.printbuf(rs->data + IPMI_LANPLUS_OFFSET_AUTHTYPE, + rs->data_len - IPMI_LANPLUS_OFFSET_AUTHTYPE - authcode_length, + "Authcode Input Data"); + h.printbuf(generated_authcode, generated_authcode_length, "Generated authcode"); + h.printbuf(bmc_authcode, authcode_length, "Expected authcode"); + } + + assert(generated_authcode_length >= authcode_length); + return (memcmp(bmc_authcode, generated_authcode, authcode_length) == 0); +} + + + +/* + * decrypt_payload + * + * + * param input points to the beginning of the payload (which will be the IV if + * we are using AES) + * param payload_size [out] will be set to the size of the payload EXCLUDING + * padding + * + * returns 0 on success (we were able to successfully decrypt the packet) + * 1 on failure (we were unable to successfully decrypt the packet) + */ +template <> int LANPlusCrypt<LANPlus>::decrypt_payload(uint8_t crypt_alg, const uint8_t * key, + const uint8_t * input, uint32_t input_length, + uint8_t * output, uint16_t * payload_size) +{ + uint8_t * decrypted_payload; + uint32_t bytes_decrypted; + + if (crypt_alg == IPMI_CRYPT_NONE) + { + /* We are not encrypted. The paylaod size is is everything. */ + *payload_size = input_length; + memmove(output, input, input_length); + return 0; + } + + /* We only support AES */ + assert(crypt_alg == IPMI_CRYPT_AES_CBC_128); + + decrypted_payload = (uint8_t*)malloc(input_length); + if (decrypted_payload == NULL) { + lPrintf(LOG_ERR, "ipmitool: malloc failure"); + return 1; + } + + + decrypt_aes_cbc_128(input, /* IV */ + key, /* Key */ + input + + IPMI_CRYPT_AES_CBC_128_BLOCK_SIZE, /* Data to decrypt */ + input_length - + IPMI_CRYPT_AES_CBC_128_BLOCK_SIZE, /* Input length */ + decrypted_payload, /* output */ + &bytes_decrypted); /* bytes written */ + + if (bytes_decrypted != 0) + { + /* Success */ + uint8_t conf_pad_length; + int i; + + memmove(output, + decrypted_payload, + bytes_decrypted); + + /* + * We have to determine the payload size, by substracting the padding, etc. + * The last byte of the decrypted payload is the confidentiality pad length. + */ + conf_pad_length = decrypted_payload[bytes_decrypted - 1]; + *payload_size = bytes_decrypted - conf_pad_length - 1; + + /* + * Extra test to make sure that the padding looks like it should (should start + * with 0x01, 0x02, 0x03, etc... + */ + for (i = 0; i < conf_pad_length; ++i) + { + if (decrypted_payload[*payload_size + i] != (i + 1)) + { + lPrintf(LOG_ERR, "Malformed payload padding"); + assert(0); + } + } + } + else + { + lPrintf(LOG_ERR, "ERROR: decrypt_aes_cbc_128 decryptd 0 bytes"); + assert(0); + } + + free(decrypted_payload); + decrypted_payload = NULL; + return (bytes_decrypted == 0); +} +template class LANPlusCrypt<LANPlus>; +template class LANPlusCrypt<lan>; diff --git a/Online/IPMI/src/NewLib/lanplus_crypt.h b/Online/IPMI/src/NewLib/lanplus_crypt.h new file mode 100755 index 0000000000000000000000000000000000000000..f784b2584de5b42302e96133fe222674ce4d1e08 --- /dev/null +++ b/Online/IPMI/src/NewLib/lanplus_crypt.h @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. + * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. + * SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE + * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING + * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL + * SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, + * OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR + * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF + * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, + * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + */ + +#ifndef IPMI_LANPLUS_CRYPT_H +#define IPMI_LANPLUS_CRYPT_H + +//#include "ipmi_intf.h" +//#include "LANPlus.h" +/* + * See the implementation file for documentation + * ipmi_intf can be used for oem specific implementations + * e.g. if (ipmi_oem_active(intf, "OEM_XYZ")) + */ +#include <stdint.h> +template <class G> class ipmi_intf; +template <class G> class ipmi_session; +template <class G> class ipmi_oem; +//class LANPlus; +template <class T> class LANPlusCrypt +{ + public: +// ipmi_helper h; + ipmi_oem<T> *oemO; + LANPlusCrypt(ipmi_oem<T> *oem) + { + oemO = oem; + } + int rakp2_hmac_matches( ipmi_session<T> * session, + const uint8_t * hmac, + ipmi_intf<T> * intf); + int rakp4_hmac_matches(ipmi_session<T> * session, + const uint8_t * hmac, + ipmi_intf<T> * intf); + int generate_rakp3_authcode(uint8_t * buffer, + ipmi_session<T> * session, + uint32_t * auth_length, + ipmi_intf<T> * intf); + int generate_sik(ipmi_session<T>* session, ipmi_intf<T> * intf); + int generate_k1(ipmi_session<T> * session); + int generate_k2(ipmi_session<T> * session); + int encrypt_payload(uint8_t crypt_alg, + const uint8_t * key, + const uint8_t * input, + uint32_t input_length, + uint8_t * output, + uint16_t * bytesWritten); + int decrypt_payload(uint8_t crypt_alg, + const uint8_t * key, + const uint8_t * input, + uint32_t input_length, + uint8_t * output, + uint16_t * payload_size); + int has_valid_auth_code(struct ipmi_rs * rs, + ipmi_session<T> * session); +}; + + +#endif /* IPMI_LANPLUS_CRYPT_H */ diff --git a/Online/IPMI/src/NewLib/lanplus_crypt_impl.cpp b/Online/IPMI/src/NewLib/lanplus_crypt_impl.cpp new file mode 100755 index 0000000000000000000000000000000000000000..cc9d2802eeff48364913064a3ed6fee9c90f22d9 --- /dev/null +++ b/Online/IPMI/src/NewLib/lanplus_crypt_impl.cpp @@ -0,0 +1,304 @@ +/* + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. + * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. + * SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE + * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING + * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL + * SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, + * OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR + * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF + * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, + * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + */ + +#include "log.h" +#include "ipmi_constants.h" +#include "LANPlus.h" +#include <openssl/hmac.h> +#include <openssl/evp.h> +#include <openssl/rand.h> +#include <openssl/err.h> +#include <assert.h> +#include <stdint.h> +#include "lanplus_crypt_impl.h" +#include "LANPlus.h" + + +/* + * seed_prng + * + * Seed our PRNG with the specified number of bytes from /dev/random + * + * param bytes specifies the number of bytes to read from /dev/random + * + * returns 0 on success + * 1 on failure + */ +static ipmi_helper<LANPlus> h; +int seed_prng(uint32_t bytes) +{ + if (! RAND_load_file("/dev/urandom", bytes)) + return 1; + else + return 0; +} + + + +/* + * lanplus_rand + * + * Generate a random number of the specified size + * + * param num_bytes [in] is the size of the random number to be + * generated + * param buffer [out] is where we will place our random number + * + * return 0 on success + * 1 on failure + */ +int +lanplus_rand(uint8_t * buffer, uint32_t num_bytes) +{ +#undef IPMI_LANPLUS_FAKE_RAND +#ifdef IPMI_LANPLUS_FAKE_RAND + + /* + * This code exists so that we can easily find the generated random number + * in the hex dumps. + */ + int i; + for (i = 0; i < num_bytes; ++i) + buffer[i] = 0x70 | i; + + return 0; +#else + return (! RAND_bytes(buffer, num_bytes)); +#endif +} + + + +/* + * HMAC + * + * param mac specifies the algorithm to be used, currently SHA1, SHA256 and MD5 + * are supported + * param key is the key used for HMAC generation + * param key_len is the lenght of key + * param d is the data to be MAC'd + * param n is the length of the data at d + * param md is the result of the HMAC algorithm + * param md_len is the length of md + * + * returns a pointer to md + */ +uint8_t * +HMAC(uint8_t mac, + const void *key, + int key_len, + const uint8_t *d, + int n, + uint8_t *md, + uint32_t *md_len) +{ + const EVP_MD *evp_md = NULL; + + if ((mac == IPMI_AUTH_RAKP_HMAC_SHA1) || + (mac == IPMI_INTEGRITY_HMAC_SHA1_96)) + evp_md = EVP_sha1(); + else if ((mac == IPMI_AUTH_RAKP_HMAC_MD5) || + (mac == IPMI_INTEGRITY_HMAC_MD5_128)) + evp_md = EVP_md5(); +#ifdef HAVE_CRYPTO_SHA256 + else if ((mac == IPMI_AUTH_RAKP_HMAC_SHA256) || + (mac == IPMI_INTEGRITY_HMAC_SHA256_128)) + evp_md = EVP_sha256(); +#endif /* HAVE_CRYPTO_SHA256 */ + else + { + lPrintf(LOG_DEBUG, "Invalid mac type 0x%x in HMAC\n", mac); + assert(0); + } + + return HMAC(evp_md, key, key_len, d, n, md, (unsigned int *)md_len); +} + + +/* + * encrypt_aes_cbc_128 + * + * Encrypt with the AES CBC 128 algorithm + * + * param iv is the 16 byte initialization vector + * param key is the 16 byte key used by the AES algorithm + * param input is the data to be encrypted + * param input_length is the number of bytes to be encrypted. This MUST + * be a multiple of the block size, 16. + * param output is the encrypted output + * param bytes_written is the number of bytes written. This param is set + * to 0 on failure, or if 0 bytes were input. + */ +void +encrypt_aes_cbc_128(const uint8_t * iv, + const uint8_t * key, + const uint8_t * input, + uint32_t input_length, + uint8_t * output, + uint32_t * bytes_written) +{ + EVP_CIPHER_CTX ctx; + EVP_CIPHER_CTX_init(&ctx); + EVP_EncryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL, key, iv); + EVP_CIPHER_CTX_set_padding(&ctx, 0); + + + *bytes_written = 0; + + if (input_length == 0) + return; + + if (verbose >= 5) + { + h.printbuf(iv, 16, "encrypting with this IV"); + h.printbuf(key, 16, "encrypting with this key"); + h.printbuf(input, input_length, "encrypting this data"); + } + + + /* + * The default implementation adds a whole block of padding if the input + * data is perfectly aligned. We would like to keep that from happening. + * We have made a point to have our input perfectly padded. + */ + assert((input_length % IPMI_CRYPT_AES_CBC_128_BLOCK_SIZE) == 0); + + + if(!EVP_EncryptUpdate(&ctx, output, (int *)bytes_written, input, input_length)) + { + /* Error */ + *bytes_written = 0; + return; + } + else + { + uint32_t tmplen; + + if(!EVP_EncryptFinal_ex(&ctx, output + *bytes_written, (int *)&tmplen)) + { + *bytes_written = 0; + return; /* Error */ + } + else + { + /* Success */ + *bytes_written += tmplen; + EVP_CIPHER_CTX_cleanup(&ctx); + } + } +} + + + +/* + * decrypt_aes_cbc_128 + * + * Decrypt with the AES CBC 128 algorithm + * + * param iv is the 16 byte initialization vector + * param key is the 16 byte key used by the AES algorithm + * param input is the data to be decrypted + * param input_length is the number of bytes to be decrypted. This MUST + * be a multiple of the block size, 16. + * param output is the decrypted output + * param bytes_written is the number of bytes written. This param is set + * to 0 on failure, or if 0 bytes were input. + */ +void +decrypt_aes_cbc_128(const uint8_t * iv, + const uint8_t * key, + const uint8_t * input, + uint32_t input_length, + uint8_t * output, + uint32_t * bytes_written) +{ + EVP_CIPHER_CTX ctx; + EVP_CIPHER_CTX_init(&ctx); + EVP_DecryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL, key, iv); + EVP_CIPHER_CTX_set_padding(&ctx, 0); + + + if (verbose >= 5) + { + h.printbuf(iv, 16, "decrypting with this IV"); + h.printbuf(key, 16, "decrypting with this key"); + h.printbuf(input, input_length, "decrypting this data"); + } + + + *bytes_written = 0; + + if (input_length == 0) + return; + + /* + * The default implementation adds a whole block of padding if the input + * data is perfectly aligned. We would like to keep that from happening. + * We have made a point to have our input perfectly padded. + */ + assert((input_length % IPMI_CRYPT_AES_CBC_128_BLOCK_SIZE) == 0); + + + if (!EVP_DecryptUpdate(&ctx, output, (int *)bytes_written, input, input_length)) + { + /* Error */ + lPrintf(LOG_DEBUG, "ERROR: decrypt update failed"); + *bytes_written = 0; + return; + } + else + { + uint32_t tmplen; + + if (!EVP_DecryptFinal_ex(&ctx, output + *bytes_written, (int *)&tmplen)) + { + char buffer[1000]; + ERR_error_string(ERR_get_error(), buffer); + lPrintf(LOG_DEBUG, "the ERR error %s", buffer); + lPrintf(LOG_DEBUG, "ERROR: decrypt final failed"); + *bytes_written = 0; + return; /* Error */ + } + else + { + /* Success */ + *bytes_written += tmplen; + EVP_CIPHER_CTX_cleanup(&ctx); + } + } + + if (verbose >= 5) + { + lPrintf(LOG_DEBUG, "Decrypted %d encrypted bytes", input_length); + h.printbuf(output, *bytes_written, "Decrypted this data"); + } +} diff --git a/Online/IPMI/src/NewLib/lanplus_crypt_impl.h b/Online/IPMI/src/NewLib/lanplus_crypt_impl.h new file mode 100755 index 0000000000000000000000000000000000000000..48e92d3480ddf497ec2dc8d346df19c0b257e493 --- /dev/null +++ b/Online/IPMI/src/NewLib/lanplus_crypt_impl.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. + * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. + * SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE + * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING + * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL + * SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, + * OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR + * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF + * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, + * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + */ + +#ifndef IPMI_LANPLUS_CRYPT_IMPL_H +#define IPMI_LANPLUS_CRYPT_IMPL_H + +int seed_prng(uint32_t bytes); + +int lanplus_rand(uint8_t * buffer, uint32_t num_bytes); + +uint8_t *HMAC(uint8_t mac, const void *key, int key_len, const uint8_t *d, int n, uint8_t *md, uint32_t *md_len); + +void encrypt_aes_cbc_128(const uint8_t * iv, const uint8_t * key, const uint8_t * input, uint32_t input_length, + uint8_t * output, uint32_t * bytes_written); + +void decrypt_aes_cbc_128(const uint8_t * iv, const uint8_t * key, const uint8_t * input, uint32_t input_length, + uint8_t * output, uint32_t * bytes_written); + +#endif /* IPMI_LANPLUS_CRYPT_IMPL_H */ diff --git a/Online/IPMI/src/NewLib/lanplus_dump.cpp b/Online/IPMI/src/NewLib/lanplus_dump.cpp new file mode 100755 index 0000000000000000000000000000000000000000..31f217698b814416d52005a1642fa6323efcaeab --- /dev/null +++ b/Online/IPMI/src/NewLib/lanplus_dump.cpp @@ -0,0 +1,216 @@ +/* + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. + * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. + * SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE + * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING + * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL + * SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, + * OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR + * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF + * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, + * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + */ + +#include "lanplus_crypt.h" +#include "lanplus_dump.h" +#include "LANPlus.h" +#include "helper.h" +#include "ipmi_constants.h" +extern const struct valstr ipmi_rakp_return_codes[]; +extern const struct valstr ipmi_priv_levels[]; +extern const struct valstr ipmi_auth_algorithms[]; +extern const struct valstr ipmi_integrity_algorithms[]; +extern const struct valstr ipmi_encryption_algorithms[]; + +#define DUMP_PREFIX_INCOMING "<<" +ipmi_helper<LANPlus> h; +void lanplus_dump_open_session_response(const struct ipmi_rs * rsp) +{ + if (verbose < 2) + return; + + printf("%sOPEN SESSION RESPONSE\n", DUMP_PREFIX_INCOMING); + + printf("%s Message tag : 0x%02x\n", + DUMP_PREFIX_INCOMING, + rsp->payload.open_session_response.message_tag); + printf("%s RMCP+ status : %s\n", + DUMP_PREFIX_INCOMING, + h.val2str(rsp->payload.open_session_response.rakp_return_code, + ipmi_rakp_return_codes)); + printf("%s Maximum privilege level : %s\n", + DUMP_PREFIX_INCOMING, + h.val2str(rsp->payload.open_session_response.max_priv_level, + ipmi_priv_levels)); + printf("%s Console Session ID : 0x%08lx\n", + DUMP_PREFIX_INCOMING, + (long)rsp->payload.open_session_response.console_id); + + /* only tag, status, privlvl, and console id are returned if error */ + if (rsp->payload.open_session_response.rakp_return_code != + IPMI_RAKP_STATUS_NO_ERRORS) + return; + + printf("%s BMC Session ID : 0x%08lx\n", + DUMP_PREFIX_INCOMING, + (long)rsp->payload.open_session_response.bmc_id); + printf("%s Negotiated authenticatin algorithm : %s\n", + DUMP_PREFIX_INCOMING, + h.val2str(rsp->payload.open_session_response.auth_alg, + ipmi_auth_algorithms)); + printf("%s Negotiated integrity algorithm : %s\n", + DUMP_PREFIX_INCOMING, + h.val2str(rsp->payload.open_session_response.integrity_alg, + ipmi_integrity_algorithms)); + printf("%s Negotiated encryption algorithm : %s\n", + DUMP_PREFIX_INCOMING, + h.val2str(rsp->payload.open_session_response.crypt_alg, + ipmi_encryption_algorithms)); + printf("\n"); +} + + + +void lanplus_dump_rakp2_message(const struct ipmi_rs * rsp, uint8_t auth_alg) +{ + int i; + + if (verbose < 2) + return; + + printf("%sRAKP 2 MESSAGE\n", DUMP_PREFIX_INCOMING); + + printf("%s Message tag : 0x%02x\n", + DUMP_PREFIX_INCOMING, + rsp->payload.rakp2_message.message_tag); + + printf("%s RMCP+ status : %s\n", + DUMP_PREFIX_INCOMING, + h.val2str(rsp->payload.rakp2_message.rakp_return_code, + ipmi_rakp_return_codes)); + + printf("%s Console Session ID : 0x%08lx\n", + DUMP_PREFIX_INCOMING, + (long)rsp->payload.rakp2_message.console_id); + + printf("%s BMC random number : 0x", DUMP_PREFIX_INCOMING); + for (i = 0; i < 16; ++i) + printf("%02x", rsp->payload.rakp2_message.bmc_rand[i]); + printf("\n"); + + printf("%s BMC GUID : 0x", DUMP_PREFIX_INCOMING); + for (i = 0; i < 16; ++i) + printf("%02x", rsp->payload.rakp2_message.bmc_guid[i]); + printf("\n"); + + switch(auth_alg) + { + case IPMI_AUTH_RAKP_NONE: + printf("%s Key exchange auth code : none\n", DUMP_PREFIX_INCOMING); + break; + case IPMI_AUTH_RAKP_HMAC_SHA1: + printf("%s Key exchange auth code [sha1] : 0x", DUMP_PREFIX_INCOMING); + for (i = 0; i < IPMI_SHA_DIGEST_LENGTH; ++i) { + printf("%02x", rsp->payload.rakp2_message.key_exchange_auth_code[i]); + } + printf("\n"); + break; + case IPMI_AUTH_RAKP_HMAC_MD5: + printf("%s Key exchange auth code [md5] : 0x", DUMP_PREFIX_INCOMING); + for (i = 0; i < IPMI_MD5_DIGEST_LENGTH; ++i) { + printf("%02x", rsp->payload.rakp2_message.key_exchange_auth_code[i]); + } + printf("\n"); + break; +#ifdef HAVE_CRYPTO_SHA256 + case IPMI_AUTH_RAKP_HMAC_SHA256: + printf("%s Key exchange auth code [sha256]: 0x", DUMP_PREFIX_INCOMING); + for (i = 0; i < IPMI_SHA256_DIGEST_LENGTH; ++i) { + printf("%02x", rsp->payload.rakp2_message.key_exchange_auth_code[i]); + } + printf("\n"); + break; +#endif /* HAVE_CRYPTO_SHA256 */ + default: + printf("%s Key exchange auth code : invalid", DUMP_PREFIX_INCOMING); + } + printf("\n"); +} + + + +void lanplus_dump_rakp4_message(const struct ipmi_rs * rsp, uint8_t auth_alg) +{ + int i; + + if (verbose < 2) + return; + + printf("%sRAKP 4 MESSAGE\n", DUMP_PREFIX_INCOMING); + + printf("%s Message tag : 0x%02x\n", + DUMP_PREFIX_INCOMING, + rsp->payload.rakp4_message.message_tag); + + printf("%s RMCP+ status : %s\n", + DUMP_PREFIX_INCOMING, + h.val2str(rsp->payload.rakp4_message.rakp_return_code, + ipmi_rakp_return_codes)); + + printf("%s Console Session ID : 0x%08lx\n", + DUMP_PREFIX_INCOMING, + (long)rsp->payload.rakp4_message.console_id); + + switch(auth_alg) + { + case IPMI_AUTH_RAKP_NONE: + printf("%s Key exchange auth code : none\n", DUMP_PREFIX_INCOMING); + break; + case IPMI_AUTH_RAKP_HMAC_SHA1: + printf("%s Key exchange auth code [sha1] : 0x", DUMP_PREFIX_INCOMING); + for (i = 0; i < IPMI_SHA1_AUTHCODE_SIZE; ++i) { + printf("%02x", rsp->payload.rakp4_message.integrity_check_value[i]); + } + printf("\n"); + break; + case IPMI_AUTH_RAKP_HMAC_MD5: + printf("%s Key exchange auth code [md5] : 0x", DUMP_PREFIX_INCOMING); + for (i = 0; i < IPMI_HMAC_MD5_AUTHCODE_SIZE; ++i) { + printf("%02x", rsp->payload.rakp4_message.integrity_check_value[i]); + } + printf("\n"); + break; +#ifdef HAVE_CRYPTO_SHA256 + case IPMI_AUTH_RAKP_HMAC_SHA256: + printf("%s Key exchange auth code [sha256]: 0x", DUMP_PREFIX_INCOMING); + for (i = 0; i < IPMI_HMAC_SHA256_AUTHCODE_SIZE; ++i) { + printf("%02x", rsp->payload.rakp4_message.integrity_check_value[i]); + } + printf("\n"); + break; +#endif /* HAVE_CRYPTO_SHA256 */ + default: + printf("%s Key exchange auth code : invalid", DUMP_PREFIX_INCOMING); + } + printf("\n"); +} + diff --git a/Online/IPMI/src/NewLib/lanplus_dump.h b/Online/IPMI/src/NewLib/lanplus_dump.h new file mode 100755 index 0000000000000000000000000000000000000000..fa8d5d38ca28ae9c3f879161e6eac8ac145ad2eb --- /dev/null +++ b/Online/IPMI/src/NewLib/lanplus_dump.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. + * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. + * SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE + * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING + * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL + * SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, + * OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR + * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF + * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, + * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + */ + + +#ifndef IPMI_LANPLUS_DUMP_H +#define IPMI_LANPLUS_DUMP_H +#include "stdint.h" +//#include "ipmi_intf.h" + +/* See the implementation file for documentation */ +void lanplus_dump_open_session_response(const struct ipmi_rs * rsp); +void lanplus_dump_rakp2_message(const struct ipmi_rs * rsp, uint8_t auth_alg); +void lanplus_dump_rakp4_message(const struct ipmi_rs * rsp, uint8_t auth_alg); + + +#endif /* IPMI_LANPLUS_DUMP_H */ diff --git a/Online/IPMI/src/NewLib/log.cpp b/Online/IPMI/src/NewLib/log.cpp index 25281816f44b6290a2e688957676e76d16c960ec..1231ded277c785e54a617bc590058bd87661d554 100644 --- a/Online/IPMI/src/NewLib/log.cpp +++ b/Online/IPMI/src/NewLib/log.cpp @@ -90,7 +90,7 @@ int fPrintf(_IO_FILE* fd, const char *fmt, ...) { va_list vptr; va_start(vptr, fmt); - fprintf(fd,"%s: ",MyUTGID); +// fprintf(fd,"%s: ",MyUTGID); vfprintf(fd,fmt,vptr); va_end(vptr); return 0; @@ -100,6 +100,7 @@ int Printf(const char *fmt, ...) { va_list vptr; va_start(vptr, fmt); + time(0); printf("%s: ",MyUTGID); vprintf(fmt,vptr); va_end(vptr); diff --git a/Online/IPMI/src/NewLib/md5.cpp b/Online/IPMI/src/NewLib/md5.cpp new file mode 100755 index 0000000000000000000000000000000000000000..6ee618ece3687978599769f7e0634765af988191 --- /dev/null +++ b/Online/IPMI/src/NewLib/md5.cpp @@ -0,0 +1,381 @@ +/* + Copyright (C) 1999, 2000, 2002 Aladdin Enterprises. All rights reserved. + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + L. Peter Deutsch + ghost@aladdin.com + + */ +/* $Id: md5.c,v 1.1 2003/11/18 17:56:02 iceblink Exp $ */ +/* + Independent implementation of MD5 (RFC 1321). + + This code implements the MD5 Algorithm defined in RFC 1321, whose + text is available at + http://www.ietf.org/rfc/rfc1321.txt + The code is derived from the text of the RFC, including the test suite + (section A.5) but excluding the rest of Appendix A. It does not include + any code or documentation that is identified in the RFC as being + copyrighted. + + The original and principal author of md5.c is L. Peter Deutsch + <ghost@aladdin.com>. Other authors are noted in the change history + that follows (in reverse chronological order): + + 2002-04-13 lpd Clarified derivation from RFC 1321; now handles byte order + either statically or dynamically; added missing #include <string.h> + in library. + 2002-03-11 lpd Corrected argument list for main(), and added int return + type, in test program and T value program. + 2002-02-21 lpd Added missing #include <stdio.h> in test program. + 2000-07-03 lpd Patched to eliminate warnings about "constant is + unsigned in ANSI C, signed in traditional"; made test program + self-checking. + 1999-11-04 lpd Edited comments slightly for automatic TOC extraction. + 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5). + 1999-05-03 lpd Original version. + */ + +#include "md5.h" +#include <string.h> + +#undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */ +#ifdef ARCH_IS_BIG_ENDIAN +# define BYTE_ORDER (ARCH_IS_BIG_ENDIAN ? 1 : -1) +#else +# define BYTE_ORDER 0 +#endif + +#define T_MASK ((md5_word_t)~0) +#define T1 /* 0xd76aa478 */ (T_MASK ^ 0x28955b87) +#define T2 /* 0xe8c7b756 */ (T_MASK ^ 0x173848a9) +#define T3 0x242070db +#define T4 /* 0xc1bdceee */ (T_MASK ^ 0x3e423111) +#define T5 /* 0xf57c0faf */ (T_MASK ^ 0x0a83f050) +#define T6 0x4787c62a +#define T7 /* 0xa8304613 */ (T_MASK ^ 0x57cfb9ec) +#define T8 /* 0xfd469501 */ (T_MASK ^ 0x02b96afe) +#define T9 0x698098d8 +#define T10 /* 0x8b44f7af */ (T_MASK ^ 0x74bb0850) +#define T11 /* 0xffff5bb1 */ (T_MASK ^ 0x0000a44e) +#define T12 /* 0x895cd7be */ (T_MASK ^ 0x76a32841) +#define T13 0x6b901122 +#define T14 /* 0xfd987193 */ (T_MASK ^ 0x02678e6c) +#define T15 /* 0xa679438e */ (T_MASK ^ 0x5986bc71) +#define T16 0x49b40821 +#define T17 /* 0xf61e2562 */ (T_MASK ^ 0x09e1da9d) +#define T18 /* 0xc040b340 */ (T_MASK ^ 0x3fbf4cbf) +#define T19 0x265e5a51 +#define T20 /* 0xe9b6c7aa */ (T_MASK ^ 0x16493855) +#define T21 /* 0xd62f105d */ (T_MASK ^ 0x29d0efa2) +#define T22 0x02441453 +#define T23 /* 0xd8a1e681 */ (T_MASK ^ 0x275e197e) +#define T24 /* 0xe7d3fbc8 */ (T_MASK ^ 0x182c0437) +#define T25 0x21e1cde6 +#define T26 /* 0xc33707d6 */ (T_MASK ^ 0x3cc8f829) +#define T27 /* 0xf4d50d87 */ (T_MASK ^ 0x0b2af278) +#define T28 0x455a14ed +#define T29 /* 0xa9e3e905 */ (T_MASK ^ 0x561c16fa) +#define T30 /* 0xfcefa3f8 */ (T_MASK ^ 0x03105c07) +#define T31 0x676f02d9 +#define T32 /* 0x8d2a4c8a */ (T_MASK ^ 0x72d5b375) +#define T33 /* 0xfffa3942 */ (T_MASK ^ 0x0005c6bd) +#define T34 /* 0x8771f681 */ (T_MASK ^ 0x788e097e) +#define T35 0x6d9d6122 +#define T36 /* 0xfde5380c */ (T_MASK ^ 0x021ac7f3) +#define T37 /* 0xa4beea44 */ (T_MASK ^ 0x5b4115bb) +#define T38 0x4bdecfa9 +#define T39 /* 0xf6bb4b60 */ (T_MASK ^ 0x0944b49f) +#define T40 /* 0xbebfbc70 */ (T_MASK ^ 0x4140438f) +#define T41 0x289b7ec6 +#define T42 /* 0xeaa127fa */ (T_MASK ^ 0x155ed805) +#define T43 /* 0xd4ef3085 */ (T_MASK ^ 0x2b10cf7a) +#define T44 0x04881d05 +#define T45 /* 0xd9d4d039 */ (T_MASK ^ 0x262b2fc6) +#define T46 /* 0xe6db99e5 */ (T_MASK ^ 0x1924661a) +#define T47 0x1fa27cf8 +#define T48 /* 0xc4ac5665 */ (T_MASK ^ 0x3b53a99a) +#define T49 /* 0xf4292244 */ (T_MASK ^ 0x0bd6ddbb) +#define T50 0x432aff97 +#define T51 /* 0xab9423a7 */ (T_MASK ^ 0x546bdc58) +#define T52 /* 0xfc93a039 */ (T_MASK ^ 0x036c5fc6) +#define T53 0x655b59c3 +#define T54 /* 0x8f0ccc92 */ (T_MASK ^ 0x70f3336d) +#define T55 /* 0xffeff47d */ (T_MASK ^ 0x00100b82) +#define T56 /* 0x85845dd1 */ (T_MASK ^ 0x7a7ba22e) +#define T57 0x6fa87e4f +#define T58 /* 0xfe2ce6e0 */ (T_MASK ^ 0x01d3191f) +#define T59 /* 0xa3014314 */ (T_MASK ^ 0x5cfebceb) +#define T60 0x4e0811a1 +#define T61 /* 0xf7537e82 */ (T_MASK ^ 0x08ac817d) +#define T62 /* 0xbd3af235 */ (T_MASK ^ 0x42c50dca) +#define T63 0x2ad7d2bb +#define T64 /* 0xeb86d391 */ (T_MASK ^ 0x14792c6e) + + +static void +md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/) +{ + md5_word_t + a = pms->abcd[0], b = pms->abcd[1], + c = pms->abcd[2], d = pms->abcd[3]; + md5_word_t t; +#if BYTE_ORDER > 0 + /* Define storage only for big-endian CPUs. */ + md5_word_t X[16]; +#else + /* Define storage for little-endian or both types of CPUs. */ + md5_word_t xbuf[16]; + const md5_word_t *X; +#endif + + { +#if BYTE_ORDER == 0 + /* + * Determine dynamically whether this is a big-endian or + * little-endian machine, since we can use a more efficient + * algorithm on the latter. + */ + const int w = 1; + + if (*((const md5_byte_t *)&w)) /* dynamic little-endian */ +#endif +#if BYTE_ORDER <= 0 /* little-endian */ + { + /* + * On little-endian machines, we can process properly aligned + * data without copying it. + */ + if (!((data - (const md5_byte_t *)0) & 3)) { + /* data are properly aligned */ + X = (const md5_word_t *)data; + } else { + /* not aligned */ + memcpy(xbuf, data, 64); + X = xbuf; + } + } +#endif +#if BYTE_ORDER == 0 + else /* dynamic big-endian */ +#endif +#if BYTE_ORDER >= 0 /* big-endian */ + { + /* + * On big-endian machines, we must arrange the bytes in the + * right order. + */ + const md5_byte_t *xp = data; + int i; + +# if BYTE_ORDER == 0 + X = xbuf; /* (dynamic only) */ +# else +# define xbuf X /* (static only) */ +# endif + for (i = 0; i < 16; ++i, xp += 4) + xbuf[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24); + } +#endif + } + +#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) + + /* Round 1. */ + /* Let [abcd k s i] denote the operation + a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */ +#define F(x, y, z) (((x) & (y)) | (~(x) & (z))) +#define SET(a, b, c, d, k, s, Ti)\ + t = a + F(b,c,d) + X[k] + Ti;\ + a = ROTATE_LEFT(t, s) + b + /* Do the following 16 operations. */ + SET(a, b, c, d, 0, 7, T1); + SET(d, a, b, c, 1, 12, T2); + SET(c, d, a, b, 2, 17, T3); + SET(b, c, d, a, 3, 22, T4); + SET(a, b, c, d, 4, 7, T5); + SET(d, a, b, c, 5, 12, T6); + SET(c, d, a, b, 6, 17, T7); + SET(b, c, d, a, 7, 22, T8); + SET(a, b, c, d, 8, 7, T9); + SET(d, a, b, c, 9, 12, T10); + SET(c, d, a, b, 10, 17, T11); + SET(b, c, d, a, 11, 22, T12); + SET(a, b, c, d, 12, 7, T13); + SET(d, a, b, c, 13, 12, T14); + SET(c, d, a, b, 14, 17, T15); + SET(b, c, d, a, 15, 22, T16); +#undef SET + + /* Round 2. */ + /* Let [abcd k s i] denote the operation + a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */ +#define G(x, y, z) (((x) & (z)) | ((y) & ~(z))) +#define SET(a, b, c, d, k, s, Ti)\ + t = a + G(b,c,d) + X[k] + Ti;\ + a = ROTATE_LEFT(t, s) + b + /* Do the following 16 operations. */ + SET(a, b, c, d, 1, 5, T17); + SET(d, a, b, c, 6, 9, T18); + SET(c, d, a, b, 11, 14, T19); + SET(b, c, d, a, 0, 20, T20); + SET(a, b, c, d, 5, 5, T21); + SET(d, a, b, c, 10, 9, T22); + SET(c, d, a, b, 15, 14, T23); + SET(b, c, d, a, 4, 20, T24); + SET(a, b, c, d, 9, 5, T25); + SET(d, a, b, c, 14, 9, T26); + SET(c, d, a, b, 3, 14, T27); + SET(b, c, d, a, 8, 20, T28); + SET(a, b, c, d, 13, 5, T29); + SET(d, a, b, c, 2, 9, T30); + SET(c, d, a, b, 7, 14, T31); + SET(b, c, d, a, 12, 20, T32); +#undef SET + + /* Round 3. */ + /* Let [abcd k s t] denote the operation + a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */ +#define H(x, y, z) ((x) ^ (y) ^ (z)) +#define SET(a, b, c, d, k, s, Ti)\ + t = a + H(b,c,d) + X[k] + Ti;\ + a = ROTATE_LEFT(t, s) + b + /* Do the following 16 operations. */ + SET(a, b, c, d, 5, 4, T33); + SET(d, a, b, c, 8, 11, T34); + SET(c, d, a, b, 11, 16, T35); + SET(b, c, d, a, 14, 23, T36); + SET(a, b, c, d, 1, 4, T37); + SET(d, a, b, c, 4, 11, T38); + SET(c, d, a, b, 7, 16, T39); + SET(b, c, d, a, 10, 23, T40); + SET(a, b, c, d, 13, 4, T41); + SET(d, a, b, c, 0, 11, T42); + SET(c, d, a, b, 3, 16, T43); + SET(b, c, d, a, 6, 23, T44); + SET(a, b, c, d, 9, 4, T45); + SET(d, a, b, c, 12, 11, T46); + SET(c, d, a, b, 15, 16, T47); + SET(b, c, d, a, 2, 23, T48); +#undef SET + + /* Round 4. */ + /* Let [abcd k s t] denote the operation + a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */ +#define I(x, y, z) ((y) ^ ((x) | ~(z))) +#define SET(a, b, c, d, k, s, Ti)\ + t = a + I(b,c,d) + X[k] + Ti;\ + a = ROTATE_LEFT(t, s) + b + /* Do the following 16 operations. */ + SET(a, b, c, d, 0, 6, T49); + SET(d, a, b, c, 7, 10, T50); + SET(c, d, a, b, 14, 15, T51); + SET(b, c, d, a, 5, 21, T52); + SET(a, b, c, d, 12, 6, T53); + SET(d, a, b, c, 3, 10, T54); + SET(c, d, a, b, 10, 15, T55); + SET(b, c, d, a, 1, 21, T56); + SET(a, b, c, d, 8, 6, T57); + SET(d, a, b, c, 15, 10, T58); + SET(c, d, a, b, 6, 15, T59); + SET(b, c, d, a, 13, 21, T60); + SET(a, b, c, d, 4, 6, T61); + SET(d, a, b, c, 11, 10, T62); + SET(c, d, a, b, 2, 15, T63); + SET(b, c, d, a, 9, 21, T64); +#undef SET + + /* Then perform the following additions. (That is increment each + of the four registers by the value it had before this block + was started.) */ + pms->abcd[0] += a; + pms->abcd[1] += b; + pms->abcd[2] += c; + pms->abcd[3] += d; +} + +void +md5_init(md5_state_t *pms) +{ + pms->count[0] = pms->count[1] = 0; + pms->abcd[0] = 0x67452301; + pms->abcd[1] = /*0xefcdab89*/ T_MASK ^ 0x10325476; + pms->abcd[2] = /*0x98badcfe*/ T_MASK ^ 0x67452301; + pms->abcd[3] = 0x10325476; +} + +void +md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes) +{ + const md5_byte_t *p = data; + int left = nbytes; + int offset = (pms->count[0] >> 3) & 63; + md5_word_t nbits = (md5_word_t)(nbytes << 3); + + if (nbytes <= 0) + return; + + /* Update the message length. */ + pms->count[1] += nbytes >> 29; + pms->count[0] += nbits; + if (pms->count[0] < nbits) + pms->count[1]++; + + /* Process an initial partial block. */ + if (offset) { + int copy = (offset + nbytes > 64 ? 64 - offset : nbytes); + + memcpy(pms->buf + offset, p, copy); + if (offset + copy < 64) + return; + p += copy; + left -= copy; + md5_process(pms, pms->buf); + } + + /* Process full blocks. */ + for (; left >= 64; p += 64, left -= 64) + md5_process(pms, p); + + /* Process a final partial block. */ + if (left) + memcpy(pms->buf, p, left); +} + +void +md5_finish(md5_state_t *pms, md5_byte_t digest[16]) +{ + const md5_byte_t pad[64] = { + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + md5_byte_t data[8]; + int i; + + /* Save the length before padding. */ + for (i = 0; i < 8; ++i) + data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3)); + /* Pad to 56 bytes mod 64. */ + md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1); + /* Append the length. */ + md5_append(pms, data, 8); + for (i = 0; i < 16; ++i) + digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3)); +} diff --git a/Online/IPMI/src/NewLib/rmcp.h b/Online/IPMI/src/NewLib/rmcp.h index 59ed0dd89eb61a1dc6236ff38d6af8219077b225..533536d6c2b3d3bc04d64420a52d70f4efc7c8a5 100644 --- a/Online/IPMI/src/NewLib/rmcp.h +++ b/Online/IPMI/src/NewLib/rmcp.h @@ -45,7 +45,7 @@ #define IPMI_RMCP_H #include "helper.h" -#include "lan.h" +//#include "lan.h" #include "asf.h" #define RMCP_VERSION_1 0x06 @@ -105,6 +105,6 @@ struct rmcp_pong { #pragma pack(0) #endif -int handle_rmcp(struct ipmi_intf * intf, uint8_t * data, int data_len); +template <class T>int handle_rmcp( ipmi_intf<T> * intf, uint8_t * data, int data_len); #endif /* IPMI_RMCP_H */ diff --git a/Online/OnlineBase/OnlineBase/ASIO/Socket.h b/Online/OnlineBase/OnlineBase/ASIO/Socket.h index e0ee8f6dbf22cd174fb2fc8ce38974c84478c43d..e438e64a2517751840c94046ffc3fee69c184ade 100755 --- a/Online/OnlineBase/OnlineBase/ASIO/Socket.h +++ b/Online/OnlineBase/OnlineBase/ASIO/Socket.h @@ -13,7 +13,7 @@ #define ONLINEBASE_ASIO_ASIOSOCKET_H // Framework include files -#include "ASIO/Boost.h" +#include <ASIO/Boost.h> // System / Boost include files diff --git a/Online/OnlineBase/OnlineBase/ASIO/TanInterface.h b/Online/OnlineBase/OnlineBase/ASIO/TanInterface.h index f02b735266b9667158a1ee9e914be60e22d65095..fad53186733f5ff35957302daebae1d85896714f 100755 --- a/Online/OnlineBase/OnlineBase/ASIO/TanInterface.h +++ b/Online/OnlineBase/OnlineBase/ASIO/TanInterface.h @@ -13,8 +13,8 @@ #define ONLINEBASE_ASIO_TAN_TANINTERFACE_H // Framework include files -#include "TAN/TanMessage.h" -#include "TAN/TanErrno.h" +#include <TAN/TanMessage.h> +#include <TAN/TanErrno.h> #ifdef __cplusplus diff --git a/Online/OnlineBase/OnlineBase/ASIO/TcpConnection.h b/Online/OnlineBase/OnlineBase/ASIO/TcpConnection.h index 6b3d31326a11069df7298ea05b73bf0507cd0be1..1502b4a5c5abb18ede4d44b2c68d371fe0e78635 100755 --- a/Online/OnlineBase/OnlineBase/ASIO/TcpConnection.h +++ b/Online/OnlineBase/OnlineBase/ASIO/TcpConnection.h @@ -17,7 +17,7 @@ #define ONLINEBASE_ASIO_ASIOTCPCONNECTION_H // Framework include files -#include "ASIO/TcpRequestHandler.h" +#include <ASIO/TcpRequestHandler.h> // System / Boost include files #include <memory> diff --git a/Online/OnlineBase/OnlineBase/ASIO/TcpRequestHandler.h b/Online/OnlineBase/OnlineBase/ASIO/TcpRequestHandler.h index 873f38a59d21a621ac3a850719f7f5f0314745dd..f6b39d95f6109ee2550bf8d4f97cb40c29d559c2 100755 --- a/Online/OnlineBase/OnlineBase/ASIO/TcpRequestHandler.h +++ b/Online/OnlineBase/OnlineBase/ASIO/TcpRequestHandler.h @@ -17,7 +17,7 @@ #define ONLINEBASE_ASIO_ASIOTCPREQUESTHANDLER_H // Framework include files -#include "ASIO/Boost.h" +#include <ASIO/Boost.h> // System / Boost include files #include <vector> diff --git a/Online/OnlineBase/OnlineBase/ASIO/TcpServer.h b/Online/OnlineBase/OnlineBase/ASIO/TcpServer.h index 21226a268cb961f07db8905d6fdddcf72733bd9a..d61fc213b175627caf6016a0f1955916dc679fd1 100755 --- a/Online/OnlineBase/OnlineBase/ASIO/TcpServer.h +++ b/Online/OnlineBase/OnlineBase/ASIO/TcpServer.h @@ -16,8 +16,10 @@ #ifndef ONLINEBASE_ASIO_ASIOTCPSERVER_H #define ONLINEBASE_ASIO_ASIOTCPSERVER_H -// System / Boost include files -#include "ASIO/TcpConnection.h" +// Boost / framework include files +#include <ASIO/TcpConnection.h> + +// System include files #include <thread> #include <string> diff --git a/Online/OnlineBase/OnlineBase/ASIO/Transfer.h b/Online/OnlineBase/OnlineBase/ASIO/Transfer.h index 1c27924d677098c0173964795583913d940f12e9..c0e0778f2856c31d6a01329f2bedad5fb9ffcaca 100755 --- a/Online/OnlineBase/OnlineBase/ASIO/Transfer.h +++ b/Online/OnlineBase/OnlineBase/ASIO/Transfer.h @@ -14,7 +14,7 @@ #define ONLINE_ZMQTRANSFER_TRANSFER_H #define TRANSFER_NS BoostAsio -#include "NET/Transfer.h" +#include <NET/Transfer.h> #undef TRANSFER_NS #endif /* ONLINE_ZMQTRANSFER_TRANSFER_H */ diff --git a/Online/OnlineBase/OnlineBase/ASIO/UnixConnection.h b/Online/OnlineBase/OnlineBase/ASIO/UnixConnection.h index bd2dd3ceca0a1ea7e09628d9db7738183a74680a..cf6c4c0c76b51d91993e9e83d38eebc211d2af46 100755 --- a/Online/OnlineBase/OnlineBase/ASIO/UnixConnection.h +++ b/Online/OnlineBase/OnlineBase/ASIO/UnixConnection.h @@ -17,7 +17,7 @@ #define ONLINEBASE_ASIO_ASIOUNIXCONNECTION_H // Framework include files -#include "ASIO/UnixRequestHandler.h" +#include <ASIO/UnixRequestHandler.h> // System / Boost include files #include <memory> diff --git a/Online/OnlineBase/OnlineBase/ASIO/UnixRequestHandler.h b/Online/OnlineBase/OnlineBase/ASIO/UnixRequestHandler.h index 3b45955b2d476120f1477a98f6530bf4db8340a8..9662af24029484764611d19544f8584cf5d496fc 100755 --- a/Online/OnlineBase/OnlineBase/ASIO/UnixRequestHandler.h +++ b/Online/OnlineBase/OnlineBase/ASIO/UnixRequestHandler.h @@ -17,7 +17,7 @@ #define ONLINEBASE_ASIO_ASIOUNIXREQUESTHANDLER_H // Framework include files -#include "ASIO/Boost.h" +#include <ASIO/Boost.h> // System / Boost include files #include <vector> diff --git a/Online/OnlineBase/OnlineBase/ASIO/UnixServer.h b/Online/OnlineBase/OnlineBase/ASIO/UnixServer.h index 20fe5dfd1e29e23ebba0028b61f035b00b741262..cf2a080ac1fdd11f6f668e01ef8fec96c35b1bcb 100755 --- a/Online/OnlineBase/OnlineBase/ASIO/UnixServer.h +++ b/Online/OnlineBase/OnlineBase/ASIO/UnixServer.h @@ -17,8 +17,8 @@ #define ONLINEBASE_ASIO_ASIOUNIXSERVER_H // System / Boost include files -#include "ASIO/UnixConnection.h" -#include "ASIO/UnixRequestHandler.h" +#include <ASIO/UnixConnection.h> +#include <ASIO/UnixRequestHandler.h> #include <thread> #include <string> diff --git a/Online/OnlineBase/OnlineBase/ASIO/UnixTransfer.h b/Online/OnlineBase/OnlineBase/ASIO/UnixTransfer.h index ed7689377dfa20625705d3532f93eb88c2cfa630..d5fc3938b778f493f2d3d36e7264dd59fc9897aa 100755 --- a/Online/OnlineBase/OnlineBase/ASIO/UnixTransfer.h +++ b/Online/OnlineBase/OnlineBase/ASIO/UnixTransfer.h @@ -14,7 +14,7 @@ #define ONLINE_ZMQTRANSFER_TRANSFER_H #define TRANSFER_NS BoostAsioIpc -#include "NET/Transfer.h" +#include <NET/Transfer.h> #undef TRANSFER_NS #endif /* ONLINE_ZMQTRANSFER_TRANSFER_H */ diff --git a/Online/OnlineBase/OnlineBase/CPP/AmsSensor.h b/Online/OnlineBase/OnlineBase/CPP/AmsSensor.h index 7f56f3f51dc6113485ee770eb3c96515dea07135..8d42aef379b8b590e368855827b056322d2cf5cd 100755 --- a/Online/OnlineBase/OnlineBase/CPP/AmsSensor.h +++ b/Online/OnlineBase/OnlineBase/CPP/AmsSensor.h @@ -13,8 +13,8 @@ #define CPP_AMSSENSOR_H /// Framework include files -#include "CPP/Sensor.h" -#include "CPP/Message.h" +#include <CPP/Sensor.h> +#include <CPP/Message.h> /// CPP namespace declaration namespace CPP { diff --git a/Online/OnlineBase/OnlineBase/CPP/AsciiDisplay.h b/Online/OnlineBase/OnlineBase/CPP/AsciiDisplay.h index 23c2d5894ff5f39541c101ef0c2b75bf8abf6ffe..0302f77c8cbc73239b6b34644222cb3a0a13d32b 100755 --- a/Online/OnlineBase/OnlineBase/CPP/AsciiDisplay.h +++ b/Online/OnlineBase/OnlineBase/CPP/AsciiDisplay.h @@ -17,14 +17,18 @@ #ifndef ONLINEKERNEL_CPP_ASCIIDISPLAY_H #define ONLINEKERNEL_CPP_ASCIIDISPLAY_H -#include <cstdlib> -#include <cstdarg> +/// Framework include files +#include <SCR/scr.h> +#include <CPP/MonitorDisplay.h> + +/// System include files +#include <map> #include <string> #include <vector> -#include <map> -#include "SCR/scr.h" -#include "CPP/MonitorDisplay.h" +#include <cstdlib> +#include <cstdarg> +/// Simple SCR based ASCII display /**@class AsciiDisplay AsciiDisplay.h CPP/AsciiDisplay.h * * Simple ASCII display implementation for monitoring applications @@ -33,11 +37,12 @@ */ class AsciiDisplay : public MonitorDisplay { public: - typedef void (*key_callback)(SCR::Pasteboard* pb, void* par, int key); + typedef int (*key_callback)(SCR::Pasteboard* pb, void* par, int key); protected: + /// Helper to store callback structure struct handler_t { key_callback call; - void* param; + void* param; }; /// Pointer to SCR pasteboard structure diff --git a/Online/OnlineBase/OnlineBase/CPP/BasicQueue.h b/Online/OnlineBase/OnlineBase/CPP/BasicQueue.h index c6c6812968f8374f2f854bf80fbcbb92e6ec48f7..5cae7fca452c39aaeb8fef45f5f69f5b593ecb10 100755 --- a/Online/OnlineBase/OnlineBase/CPP/BasicQueue.h +++ b/Online/OnlineBase/OnlineBase/CPP/BasicQueue.h @@ -12,16 +12,19 @@ #ifndef __THREADQUEUE_H_LOADED__ #define __THREADQUEUE_H_LOADED__ -#include "RTL/NoMemberAlignment.h" -#include "RTL/rtl.h" +/// Framework include files +#include <RTL/rtl.h> +#include <RTL/Pack.h> + #ifdef _VMS #define remqhi lib$remqhi #define remqti lib$remqti #define insqhi lib$insqhi #define insqti lib$insqti + #elif defined(_OSK) || defined(_WIN32) || defined(__linux) #include <cstdio> -#include "RTL/que.h" +#include <RTL/que.h> #endif /// Definition of queueable objects @@ -115,5 +118,5 @@ public: } }; -#include "RTL/RestoreMemberAlignment.h" +#include <RTL/Unpack.h> #endif diff --git a/Online/OnlineBase/OnlineBase/CPP/BasicRequest.h b/Online/OnlineBase/OnlineBase/CPP/BasicRequest.h index 12e75daddd66f5a933d7785192d67f33d61ad869..17654fe4149f3916dcfd8c932addee781c0595c7 100755 --- a/Online/OnlineBase/OnlineBase/CPP/BasicRequest.h +++ b/Online/OnlineBase/OnlineBase/CPP/BasicRequest.h @@ -11,8 +11,8 @@ //========================================================================== #ifndef __BASIC_REQUEST_LOADED_H #define __BASIC_REQUEST_LOADED_H -#include "RTL/NoMemberAlignment.h" -#include "CPP/BasicQueue.h" +#include <RTL/Pack.h> +#include <CPP/BasicQueue.h> class Worker; @@ -78,5 +78,5 @@ public: return 0; } }; -#include "RTL/RestoreMemberAlignment.h" +#include <RTL/Unpack.h> #endif diff --git a/Online/OnlineBase/OnlineBase/CPP/Collections.h b/Online/OnlineBase/OnlineBase/CPP/Collections.h index b50e99474525bc27c44ca7cb444262b0bd875a01..47d17c30d3545fa194e004885b109f5cc990c46c 100755 --- a/Online/OnlineBase/OnlineBase/CPP/Collections.h +++ b/Online/OnlineBase/OnlineBase/CPP/Collections.h @@ -17,7 +17,7 @@ #include <climits> #include <iomanip> #include <iostream> -#include "RTL/Pack.h" +#include <RTL/Pack.h> /* * Online namespace declaration @@ -225,7 +225,7 @@ namespace Online { } } -#include "RTL/Unpack.h" +#include <RTL/Unpack.h> #endif /* ONLINE_COLLECTIONS_H */ diff --git a/Online/OnlineBase/OnlineBase/CPP/Interactor.h b/Online/OnlineBase/OnlineBase/CPP/Interactor.h index 5adc93d987a6e4276f9b4f3245d93f1d8dc9b459..f5fc587fc8dc6526816c7d7a5bfb8f8f03993e7f 100755 --- a/Online/OnlineBase/OnlineBase/CPP/Interactor.h +++ b/Online/OnlineBase/OnlineBase/CPP/Interactor.h @@ -14,7 +14,7 @@ #ifndef CPP_INTERACTOR_H #define CPP_INTERACTOR_H 1 -#include "CPP/Sensor.h" +#include <CPP/Sensor.h> /// CPP namespace declaration namespace CPP { diff --git a/Online/OnlineBase/OnlineBase/CPP/IocLogDevice.h b/Online/OnlineBase/OnlineBase/CPP/IocLogDevice.h index 0ca5469d45fd9b19f62e5a3515c8f0e53a817374..93d8c5bd3cef3832589e4b024890c4b12d55c717 100644 --- a/Online/OnlineBase/OnlineBase/CPP/IocLogDevice.h +++ b/Online/OnlineBase/OnlineBase/CPP/IocLogDevice.h @@ -13,7 +13,7 @@ #define ONLINEBASE_RTL_FCMLOGDEVICE_H /// Framework include files -#include "RTL/Logger.h" +#include <RTL/Logger.h> /// RTL namespace declaration namespace CPP { diff --git a/Online/OnlineBase/OnlineBase/CPP/IocSensor.h b/Online/OnlineBase/OnlineBase/CPP/IocSensor.h index f120dc97a612e416f138c91d63263ea9faf5825a..e9757b415f179a0816964bb155d7c07c49bad4cd 100755 --- a/Online/OnlineBase/OnlineBase/CPP/IocSensor.h +++ b/Online/OnlineBase/OnlineBase/CPP/IocSensor.h @@ -12,8 +12,8 @@ #ifndef CPP_IOCSENSOR_H #define CPP_IOCSENSOR_H 1 -#include "CPP/Sensor.h" - +/// Framework include files +#include <CPP/Sensor.h> /// CPP namespace declaration namespace CPP { diff --git a/Online/OnlineBase/OnlineBase/CPP/PubArea.h b/Online/OnlineBase/OnlineBase/CPP/PubArea.h index 71f29f468f2ac235d1e0d1b41c55d60bfa603358..2ff76e1de25849d99f18c11e07db400fb72a0ac1 100755 --- a/Online/OnlineBase/OnlineBase/CPP/PubArea.h +++ b/Online/OnlineBase/OnlineBase/CPP/PubArea.h @@ -11,8 +11,13 @@ //========================================================================== #ifndef _PUBAREA_H #define _PUBAREA_H -#include "CPP/passdef.h" + +/// Framework include files +#include <CPP/passdef.h> + +/// C++ include files #include <cstdlib> + // *************** // *** PubArea *** // *************** diff --git a/Online/OnlineBase/OnlineBase/CPP/Sensor.h b/Online/OnlineBase/OnlineBase/CPP/Sensor.h index 9d7ada12a632aeb9e0a368adc82fff8bcccf1c7a..b5f9d0b4da9574b2c5105292ba429996252d98ee 100755 --- a/Online/OnlineBase/OnlineBase/CPP/Sensor.h +++ b/Online/OnlineBase/OnlineBase/CPP/Sensor.h @@ -23,9 +23,8 @@ ** {@tbs@}... **-- */ - -#ifndef __SENSOR -#define __SENSOR 1 +#ifndef _CPP_SENSOR +#define _CPP_SENSOR 1 // C/C++ include files #include <string> @@ -60,4 +59,5 @@ namespace CPP { }; } using CPP::Sensor; -#endif +#endif // _CPP_SENSOR + diff --git a/Online/OnlineBase/OnlineBase/CPP/SmartObject.h b/Online/OnlineBase/OnlineBase/CPP/SmartObject.h index af39fe7cf7a95d78b27cdbaea6c4e9c82c0bb368..1b97c211406a1ac2a4d3d71f14e52f1df0c080b1 100755 --- a/Online/OnlineBase/OnlineBase/CPP/SmartObject.h +++ b/Online/OnlineBase/OnlineBase/CPP/SmartObject.h @@ -11,8 +11,9 @@ //========================================================================== #ifndef __SMARTOBJECT_H__ #define __SMARTOBJECT_H__ + #ifdef __cplusplus -#include "NET/defs.h" +#include <NET/defs.h> /// Useful template class for object, which may fail /** @class SmartObject diff --git a/Online/OnlineBase/OnlineBase/CPP/TimeSensor.h b/Online/OnlineBase/OnlineBase/CPP/TimeSensor.h index 878403030a20393fe8bf6d9e6f6b10784b44f8cd..a7c2d122e344a0dc2bfac3f7363f2df4f1ac25c4 100755 --- a/Online/OnlineBase/OnlineBase/CPP/TimeSensor.h +++ b/Online/OnlineBase/OnlineBase/CPP/TimeSensor.h @@ -27,7 +27,8 @@ #ifndef CPP_TIMESENSOR_H #define CPP_TIMESENSOR_H -#include "CPP/Sensor.h" +/// Framework include files +#include <CPP/Sensor.h> /// CPP namespace declaration namespace CPP { diff --git a/Online/OnlineBase/OnlineBase/LOG/FifoLog.inl.h b/Online/OnlineBase/OnlineBase/LOG/FifoLog.inl.h index a5759be994fef79220148acb5a1a776bc75653fb..836b5b03b8a2c7773312b8ab92a7e52e0ea31735 100644 --- a/Online/OnlineBase/OnlineBase/LOG/FifoLog.inl.h +++ b/Online/OnlineBase/OnlineBase/LOG/FifoLog.inl.h @@ -329,6 +329,9 @@ namespace fifolog { if ( tag.empty() || tag == "SYSTEM" ) { tag = ::getenv("PARTITION_NAME") ? ::getenv("PARTITION_NAME") : tag; } + if ( tag.empty() || tag == "SYSTEM" ) { + tag = ::getenv("SYSTEM_TAG") ? ::getenv("SYSTEM_TAG") : tag; + } if ( tag.empty() ) { tag = "SYSTEM"; } @@ -784,7 +787,7 @@ extern "C" void fifolog_finalize_logger() { if ( log.get() ) { log->stop(); log.reset(); - ::fprintf(stderr, "\nFinalizing dim logger....\n"); + ::fprintf(stderr, "\nFinalizing output logger....\n"); } } diff --git a/Online/OnlineBase/OnlineBase/RTL/DoubleLinkedQueue.h b/Online/OnlineBase/OnlineBase/RTL/DoubleLinkedQueue.h index fd069363c9cef7c88b0fdfd74886fa52c99b9f9c..abe2c5c814795273b480c4a570a01d50e45d523c 100755 --- a/Online/OnlineBase/OnlineBase/RTL/DoubleLinkedQueue.h +++ b/Online/OnlineBase/OnlineBase/RTL/DoubleLinkedQueue.h @@ -15,7 +15,8 @@ #ifndef __QUE_DOUBLELINKEDQUEUE_H__ #define __QUE_DOUBLELINKEDQUEUE_H__ -#include "RTL/que.h" +#include <RTL/que.h> +#include <RTL/rtl.h> /* * namespace RTL diff --git a/Online/OnlineBase/OnlineBase/RTL/Lock.h b/Online/OnlineBase/OnlineBase/RTL/Lock.h deleted file mode 100755 index 3e42f2c67d5bd5c00a963391f9fec2c441868996..0000000000000000000000000000000000000000 --- a/Online/OnlineBase/OnlineBase/RTL/Lock.h +++ /dev/null @@ -1,51 +0,0 @@ -//========================================================================== -// LHCb Online software suite -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see OnlineSys/LICENSE. -// -// Author : M.Frank -// -//========================================================================== -#ifndef _RTL_LOCK_H -#define _RTL_LOCK_H - -#include "RTL/rtl.h" - -/* - * RTL namespace declaration - */ -namespace RTL { - - /**@class Lock Lock.h RTL/Lock.h - */ - class Lock { - /// Execution mode (inverted or not - bool m_mode; - /// Lock status - int m_status; - /// Lock identifier - lib_rtl_lock_t m_id; - public: - /// Initializing constructor for inverted lock - explicit Lock(lib_rtl_lock_t id, bool inverted=false); - /// Standard destructor - ~Lock(); - /// Create now named lock - static int create(const char* name, lib_rtl_lock_t& id); - /// Delete lock - static int unlink(lib_rtl_lock_t id); - /// Validity check - operator int () { - return lib_rtl_is_success(m_status); - } - /// Access to object status - int status() const { - return m_status; - } - }; -} - -#endif // _RTL_LOCK_H diff --git a/Online/OnlineBase/OnlineBase/RTL/NoMemberAlignment.h b/Online/OnlineBase/OnlineBase/RTL/NoMemberAlignment.h deleted file mode 100755 index 30d6b3c727a185a3ec68245e05ac646ca01f8613..0000000000000000000000000000000000000000 --- a/Online/OnlineBase/OnlineBase/RTL/NoMemberAlignment.h +++ /dev/null @@ -1,15 +0,0 @@ -//========================================================================== -// LHCb Online software suite -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see OnlineSys/LICENSE. -// -// Author : M.Frank -// -//========================================================================== -#ifdef _VMS -#pragma member_alignment save -#pragma nomember_alignment -#endif diff --git a/Online/OnlineBase/OnlineBase/RTL/Pack.h b/Online/OnlineBase/OnlineBase/RTL/Pack.h index 0e3a2c8fd9c007c52e9b40b825d401e2cabf6c46..a350de7e3a656b304ee5ad9cb16ed7a6c30badd9 100755 --- a/Online/OnlineBase/OnlineBase/RTL/Pack.h +++ b/Online/OnlineBase/OnlineBase/RTL/Pack.h @@ -18,7 +18,13 @@ #pragma pack(push, datamember_aligment, 1) #define PACK_DATA(x) x #define PACKED_DATA + +#elif defined(_VMS) +#pragma member_alignment save +#pragma nomember_alignment + #else + #define PACK_DATA(x) x __attribute__((__packed__)) #define PACKED_DATA __attribute__((__packed__)) #pragma GCC diagnostic push diff --git a/Online/OnlineBase/OnlineBase/RTL/RestoreMemberAlignment.h b/Online/OnlineBase/OnlineBase/RTL/RestoreMemberAlignment.h deleted file mode 100755 index b2c324b634ade522e0ad50193dab4e26ae2f1805..0000000000000000000000000000000000000000 --- a/Online/OnlineBase/OnlineBase/RTL/RestoreMemberAlignment.h +++ /dev/null @@ -1,14 +0,0 @@ -//========================================================================== -// LHCb Online software suite -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see OnlineSys/LICENSE. -// -// Author : M.Frank -// -//========================================================================== -#ifdef _VMS -#pragma member_alignment restore -#endif diff --git a/Online/OnlineBase/OnlineBase/RTL/Sys.h b/Online/OnlineBase/OnlineBase/RTL/Sys.h index 5fd9693cf43d2b6deff20b76234a4986ed6a6635..fbc31641dfd7e560cbc558f50750aae30b215658 100755 --- a/Online/OnlineBase/OnlineBase/RTL/Sys.h +++ b/Online/OnlineBase/OnlineBase/RTL/Sys.h @@ -19,7 +19,7 @@ #include <set> // Framework include files -#include "RTL/Pack.h" +#include <RTL/Pack.h> /// ROMon namespace declaration namespace RTL { @@ -385,7 +385,7 @@ namespace RTL { /// Retrive the processor IDs of a node from the SystemCPU blocks std::set<int> processor_ids(const std::vector<SystemCPU>& data, int cpu_slot=-1); } -#include "RTL/Unpack.h" +#include <RTL/Unpack.h> #define _PROCFILE_NAME(len,name) \ namespace { const char* fn_process_##name (int pid) { \ diff --git a/Online/OnlineBase/OnlineBase/RTL/SysTime.h b/Online/OnlineBase/OnlineBase/RTL/SysTime.h index c04cc82093393e33dce51a942ece4e735be69006..85e020c3aeb89ddc2f6ddcfea16213de15336e64 100755 --- a/Online/OnlineBase/OnlineBase/RTL/SysTime.h +++ b/Online/OnlineBase/OnlineBase/RTL/SysTime.h @@ -12,8 +12,8 @@ #ifndef _RTL_SYSTIME_H #define _RTL_SYSTIME_H -#include "RTL/rtl.h" -#include "RTL/que.h" +#include <RTL/rtl.h> +#include <RTL/que.h> /* * RTL namespace declaration diff --git a/Online/OnlineBase/OnlineBase/RTL/Thread.h b/Online/OnlineBase/OnlineBase/RTL/Thread.h deleted file mode 100755 index b84f6d3e57042afc1666ab1b6488318ac506fa53..0000000000000000000000000000000000000000 --- a/Online/OnlineBase/OnlineBase/RTL/Thread.h +++ /dev/null @@ -1,47 +0,0 @@ -//========================================================================== -// LHCb Online software suite -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see OnlineSys/LICENSE. -// -// Author : M.Frank -// -//========================================================================== -#ifndef _RTL_THREAD_H -#define _RTL_THREAD_H - -#include "RTL/rtl.h" - -/* - * RTL namespace declaration - */ -namespace RTL { - - /**@class Thread Thread.h RTL/Thread.h - */ - class Thread { - /// Thread status - int m_status; - /// Thread identifier - //lib_rtl_thread_t m_id; - public: - /// Initializing constructor - Thread(); - /// Standard destructor - virtual ~Thread(); - /// Create now named Thread - static int create(const char* name, lib_rtl_thread_t& id); - /// Validity check - operator int () { - return lib_rtl_is_success(m_status); - } - /// Access to object status - int status() const { - return m_status; - } - }; -} - -#endif // _RTL_THREAD_H diff --git a/Online/OnlineBase/OnlineBase/RTL/TimerManager.h b/Online/OnlineBase/OnlineBase/RTL/TimerManager.h index 609de927504f1ededa2947a668353d412f828c21..b74bdf1a59409c74f4d7f209b56f016b97f1c9e9 100755 --- a/Online/OnlineBase/OnlineBase/RTL/TimerManager.h +++ b/Online/OnlineBase/OnlineBase/RTL/TimerManager.h @@ -12,8 +12,8 @@ #ifndef _RTL_TIMERMANAGER_H #define _RTL_TIMERMANAGER_H -#include "RTL/rtl.h" -#include "RTL/que.h" +#include <RTL/rtl.h> +#include <RTL/que.h> #include <thread> #include <mutex> @@ -22,6 +22,7 @@ */ namespace RTL { + /// Timer entry structural definition struct timer_entry_t : public qentry_t { timer_entry_t() : qentry_t(0,0), magic(0), expire(0), hdl(0), ast(0), param(0), period(0) {} unsigned int magic; diff --git a/Online/OnlineBase/OnlineBase/RTL/Unpack.h b/Online/OnlineBase/OnlineBase/RTL/Unpack.h index 3ba3e52ede09b35d5c18faecd2706eaaa7eb2b3c..c0123d72232b955b4ed7a1cc63cc84076d483f54 100755 --- a/Online/OnlineBase/OnlineBase/RTL/Unpack.h +++ b/Online/OnlineBase/OnlineBase/RTL/Unpack.h @@ -11,10 +11,16 @@ //========================================================================== #undef PACK_DATA #undef PACKED_DATA + #ifdef _WIN32 #pragma pack(pop, datamember_aligment) + +#elif defined(_VMS) +#pragma member_alignment restore + #elif defined(__clang__) || defined(__CLING__) #pragma clang diagnostic pop + #elif defined(__GNUC__) && __GNUC__ >= 5 #pragma GCC diagnostic pop #endif diff --git a/Online/OnlineBase/OnlineBase/RTL/que.h b/Online/OnlineBase/OnlineBase/RTL/que.h index 750dfd53e78af9129f8645034bb3d3d55f154303..5e132c7bf6806cddd2caa02d232327766091fb94 100755 --- a/Online/OnlineBase/OnlineBase/RTL/que.h +++ b/Online/OnlineBase/OnlineBase/RTL/que.h @@ -14,7 +14,7 @@ */ #ifndef __QUE_H__ #define __QUE_H__ -#include "RTL/Pack.h" +#include <RTL/Pack.h> struct qentry { qentry *next; qentry *prev; @@ -41,11 +41,12 @@ static inline bool lib_rtl_queue_success(int sc) { return (sc > 0); } #else #define rtl_queue_success(sc) ((sc) > 0 ) #endif +#include <RTL/Unpack.h> + #define QUE_SUCCESS 1 #define QUE_ONEENTQUE 2 #define QUE_QUEISEMPTY 3 #define QUE_QUEWASEMPTY -3 -#include "RTL/Unpack.h" #endif diff --git a/Online/OnlineBase/OnlineBase/RTL/raiseDebug.h b/Online/OnlineBase/OnlineBase/RTL/raiseDebug.h index 492083f280fc853b52628320a455313f866aa88d..f976c222ff514b0e615dd624b6183e56446f914b 100644 --- a/Online/OnlineBase/OnlineBase/RTL/raiseDebug.h +++ b/Online/OnlineBase/OnlineBase/RTL/raiseDebug.h @@ -21,7 +21,4 @@ void raiseDebug(void); - - - #endif /* ONLINE_ONLINEBASE_ONLINEBASE_RTL_RAISEDEBUG_H_ */ diff --git a/Online/OnlineBase/OnlineBase/RTL/screen.h b/Online/OnlineBase/OnlineBase/RTL/screen.h index d162a4b8ce531422018980c62de7e8889cd4d4cd..3e62e621dcdad224b4e58e6bdb5ce143444c85ed 100755 --- a/Online/OnlineBase/OnlineBase/RTL/screen.h +++ b/Online/OnlineBase/OnlineBase/RTL/screen.h @@ -16,7 +16,7 @@ #if defined(_WIN32) -#include "RTL/conioex.h" +#include <RTL/conioex.h> typedef void* WINDOW; static inline void ascii() { } static inline void graphics() { } diff --git a/Online/OnlineBase/OnlineBase/TAN/TanDB.h b/Online/OnlineBase/OnlineBase/TAN/TanDB.h index b2a7eaee1d9a72f20a50e8942c32b90843765bf4..12810d50e49d516a37c1dcf0440b689c15df595c 100755 --- a/Online/OnlineBase/OnlineBase/TAN/TanDB.h +++ b/Online/OnlineBase/OnlineBase/TAN/TanDB.h @@ -13,8 +13,9 @@ #define ONLINEBASE_TAN_TANDB_H 1 // C/C++ include files +#include <mutex> #include <cstdio> -#include <ctype.h> +#include <cctype> #include <cstring> // Framework include files @@ -137,7 +138,7 @@ class TanDataBase : public SmartObject<TanDataBase> { /// Pointer to data in Pubarea TanPaSlot* m_data; /// Mutex to protect the database - lib_rtl_lock_t m_lock; + std::mutex m_lock; /// Internal errno int m_error; diff --git a/Online/OnlineBase/src/AMS/ams_bounce.cpp b/Online/OnlineBase/src/AMS/ams_bounce.cpp index 72321ea8e513cf386d845b890875cbf79a589663..fd5beddbb7bd4e36361a46f42f5dc6290e9aec32 100755 --- a/Online/OnlineBase/src/AMS/ams_bounce.cpp +++ b/Online/OnlineBase/src/AMS/ams_bounce.cpp @@ -10,13 +10,16 @@ // //========================================================================== +// C/C++ include files #include <cstdlib> #include <cstdio> #include <cstring> #include <string> -#include "RTL/rtl.h" -#include "WT/wtdef.h" -#include "AMS/amsdef.h" + +// Framework include files +#include <RTL/rtl.h> +#include <WT/wtdef.h> +#include <AMS/amsdef.h> #define SIZE 20000 diff --git a/Online/OnlineBase/src/AMS/ams_qmtest.cpp b/Online/OnlineBase/src/AMS/ams_qmtest.cpp index 0102b2c8e2465152c4d01090a6a4c2cbd7807d92..46fee4ef4be4b0777099a83c244c8fd3923b91bf 100755 --- a/Online/OnlineBase/src/AMS/ams_qmtest.cpp +++ b/Online/OnlineBase/src/AMS/ams_qmtest.cpp @@ -11,8 +11,8 @@ //========================================================================== #include <cstdio> #include <cstdlib> -#include "RTL/rtl.h" -#include "TAN/TanInterface.h" +#include <RTL/rtl.h> +#include <TAN/TanInterface.h> extern "C" int amsc_qmtest(int /* ac */, char** /* av */) { FILE* f; diff --git a/Online/OnlineBase/src/AMS/ams_sender.cpp b/Online/OnlineBase/src/AMS/ams_sender.cpp index c5b5b931134e8012daf3a440ed54813ee5a541c6..c5954d723687f5f1c2d2d912a2453a0656bf1f24 100755 --- a/Online/OnlineBase/src/AMS/ams_sender.cpp +++ b/Online/OnlineBase/src/AMS/ams_sender.cpp @@ -12,9 +12,9 @@ #include <cstdio> #include <string> #include <cstring> -#include "RTL/rtl.h" -#include "WT/wtdef.h" -#include "AMS/amsdef.h" +#include <RTL/rtl.h> +#include <WT/wtdef.h> +#include <AMS/amsdef.h> namespace { void fill (char *buff,int len) { diff --git a/Online/OnlineBase/src/AMS/ams_test.cpp b/Online/OnlineBase/src/AMS/ams_test.cpp index f2887320032295b407912d361c8b7432c764b8d2..2469722b310ca02a187a8c070000c4158a91afb1 100755 --- a/Online/OnlineBase/src/AMS/ams_test.cpp +++ b/Online/OnlineBase/src/AMS/ams_test.cpp @@ -9,8 +9,8 @@ // Author : M.Frank, B.Jost // //========================================================================== -#include "AMS/amsdef.h" -#include "RTL/rtl.h" +#include <AMS/amsdef.h> +#include <RTL/rtl.h> #include <cstdio> #include <cstdlib> diff --git a/Online/OnlineBase/src/AMS/ams_transfer.cpp b/Online/OnlineBase/src/AMS/ams_transfer.cpp index 83de01a82df3fce723b2d613d8025be48384c5c8..cdd2c740b7497e16fc821349f8cc310ff2db8d9e 100755 --- a/Online/OnlineBase/src/AMS/ams_transfer.cpp +++ b/Online/OnlineBase/src/AMS/ams_transfer.cpp @@ -9,9 +9,13 @@ // Author : M.Frank, B.Jost // //========================================================================== -#include "AMS/Transfer.h" -#include "AMS/amsdef.h" -#include "RTL/rtl.h" + +// Framework include files +#include <AMS/Transfer.h> +#include <AMS/amsdef.h> +#include <RTL/rtl.h> + +// C/C++ include files #include <cstdio> #include <cstdlib> #include <mutex> @@ -106,4 +110,4 @@ void AMS::net_cancel(NET* net) using namespace AMS; #define TRANSFERTEST(x) test_socket_ams_##x -#include "NET/TransferTest.h" +#include <NET/TransferTest.h> diff --git a/Online/OnlineBase/src/AMS/amslib.cpp b/Online/OnlineBase/src/AMS/amslib.cpp index 1819046a8168f1007a08a8f0ed683481313d27fa..ef651e04e26f9d21504b738afa53861f91144401 100755 --- a/Online/OnlineBase/src/AMS/amslib.cpp +++ b/Online/OnlineBase/src/AMS/amslib.cpp @@ -9,18 +9,22 @@ // Author : M.Frank, B.Jost // //========================================================================== + +// C/C++ include files #include <cstring> #include <cstdio> #include <cerrno> #include <memory> - -#include "RTL/que.h" -#include "RTL/Lock.h" -#include "RTL/strdef.h" -#include "WT/wtdef.h" -#include "AMS/amsdef.h" -#include "TAN/TanInterface.h" -#include "NET/IOPortManager.h" +#include <mutex> + +// Framework include files +#include <RTL/rtl.h> +#include <RTL/que.h> +#include <RTL/strdef.h> +#include <WT/wtdef.h> +#include <AMS/amsdef.h> +#include <TAN/TanInterface.h> +#include <NET/IOPortManager.h> // #define _USE_FULL_WT enum { @@ -46,6 +50,7 @@ static const int DEFAULT_STYLE= DECNET_STYLE; static const int SNDBUF_VALUE = 8192; static const int RCVBUF_VALUE = CHOP_SIZE; +#define LOCK std::lock_guard<std::mutex> #define DB_SIZE 256 #define WITHOUT_INTERCEPT(x) lib_rtl_disable_intercept(); \ x ; \ @@ -126,7 +131,6 @@ namespace { inited = false; userAst = 0; msgWaiting = 0; - lockid = 0; } void* wt_enable_mask; amsentry_t me; @@ -144,7 +148,7 @@ namespace { int msgWaiting; char reqSource [SAFE_NAME_LENGTH]; int reqFac; - lib_rtl_lock_t lockid; + std::mutex lockid; }; static AMS _ams; } @@ -734,7 +738,7 @@ static amsentry_t *_amsc_db_find_entry (amsentry_t **db, const char *data) { } static int _amsc_peek_action (unsigned int /* fac */, void* param) { - RTL::Lock lock(_ams.lockid); + LOCK lock(_ams.lockid); amsentry_t* e = (amsentry_t*)param; amsqueue_t* m = e ? e->pending : 0; if ( e->pending == 0 ) { // brand new message: get its length (net_to_hosted) @@ -775,7 +779,7 @@ static amsentry_t *_amsc_db_find_entry (amsentry_t **db, const char *data) { } static int _amsc_make_accept() { - RTL::Lock lock(_ams.lockid); + LOCK lock(_ams.lockid); amsentry_t *e = new amsentry_t(); int status = _amsc_tcp_accept (&_ams.me, e); if (status != AMS_SUCCESS) { @@ -844,7 +848,7 @@ static amsentry_t *_amsc_db_find_entry (amsentry_t **db, const char *data) { } if (_ams.msgWaiting == 1) { #ifdef _USE_FULL_WT - RTL::Lock lock(_ams.lockid); + LOCK lock(_ams.lockid); #endif unsigned int facility; size_t tlen, siz = 80; @@ -884,7 +888,7 @@ static amsentry_t *_amsc_db_find_entry (amsentry_t **db, const char *data) { else { _amsc_printf("Message action: No message pending!\n"); #ifdef _USE_FULL_WT - RTL::Lock lock(_ams.lockid); + LOCK lock(_ams.lockid); #endif if ( lib_rtl_queue_success(remqhi(&_ams.AMS_Q,&m)) ) { insqti (m, &_ams.message_Q); @@ -896,7 +900,7 @@ static amsentry_t *_amsc_db_find_entry (amsentry_t **db, const char *data) { static int _amsc_receive_action (unsigned int /* fac */,void* param) { #ifdef _USE_FULL_WT - RTL::Lock lock(_ams.lockid); + LOCK lock(_ams.lockid); #endif amsentry_t *e = (amsentry_t*)param; amsqueue_t *m = e->msg_ptr; @@ -1221,13 +1225,6 @@ static amsentry_t *_amsc_db_find_entry (amsentry_t **db, const char *data) { wtc_remove(WT_FACILITY_TIMEOUT); return errno=status; } - status = lib_rtl_create_lock(0, &_ams.lockid); - if ( !lib_rtl_is_success(status) ) { - lib_rtl_signal_message(LIB_RTL_OS,"Error creating AMS lock. Status %d",status); - _amsc_tcp_terminate (&_ams.me); - wtc_remove(WT_FACILITY_TCPAMS); - wtc_remove(WT_FACILITY_TIMEOUT); - } _ams.inited = true; _ams.refCount = 1; lib_rtl_declare_exit(AMS_exit_handler,0); @@ -1246,12 +1243,11 @@ static amsentry_t *_amsc_db_find_entry (amsentry_t **db, const char *data) { _amsc_disconnect_from_task (e); } } - if (_ams.lockid) amsc_flush_message_queue (); + amsc_flush_message_queue (); wtc_flush(WT_FACILITY_TCPAMS); wtc_remove(WT_FACILITY_TCPAMS); wtc_flush(WT_FACILITY_TIMEOUT); wtc_remove(WT_FACILITY_TIMEOUT); - if (_ams.lockid) lib_rtl_delete_lock(_ams.lockid); _ams.inited = false; } return AMS_SUCCESS; @@ -1259,7 +1255,7 @@ static amsentry_t *_amsc_db_find_entry (amsentry_t **db, const char *data) { void amsc_flush_message_queue (void) { amsqueue_t *m; - RTL::Lock lock(_ams.lockid); + LOCK lock(_ams.lockid); while( lib_rtl_queue_success(remqhi(&_ams.message_Q,(qentry_t**)&m)) ) { m->release(); } @@ -1267,7 +1263,7 @@ static amsentry_t *_amsc_db_find_entry (amsentry_t **db, const char *data) { int amsc_send_message (const void* buff, size_t size, const char* dest, int fac, const char* from) { CheckInitialization(); - RTL::Lock lock(_ams.lockid); + LOCK lock(_ams.lockid); return _amsc_send_message(buff,size,dest,fac,from); } @@ -1278,17 +1274,17 @@ static amsentry_t *_amsc_db_find_entry (amsentry_t **db, const char *data) { int amsc_get_message (void* buff, size_t* size, char* from, char* r_source_in, int timeout, unsigned int* facility, unsigned int r_facility, char* dest) { - RTL::Lock lock(_ams.lockid); + LOCK lock(_ams.lockid); return _amsc_get_message(buff,size,from,r_source_in,timeout,facility,r_facility,dest); } int amsc_read_message (void* buff, size_t* size, char* from, unsigned int* facility, char* dest) { - RTL::Lock lock(_ams.lockid); + LOCK lock(_ams.lockid); return _amsc_read_message(buff,size,from,facility,dest); } int amsc_read_message_long (void** buff, size_t* size, char* from, unsigned int* facility, char* dest) { - RTL::Lock lock(_ams.lockid); + LOCK lock(_ams.lockid); return _amsc_read_message_long(buff,size,from,facility,dest); } @@ -1314,25 +1310,25 @@ static amsentry_t *_amsc_db_find_entry (amsentry_t **db, const char *data) { int amsc_spy_next_message (void* buffer, size_t* size, char* from, unsigned int* facility, size_t* tlen) { CheckInitialization(); - RTL::Lock lock(_ams.lockid); + LOCK lock(_ams.lockid); return _amsc_spy_next_message(buffer,size,from,facility,tlen,&_ams.message_Q); } int amsc_spy_last_message (void* buffer, size_t* size, char* from, unsigned int* facility, size_t* tlen) { CheckInitialization(); - RTL::Lock lock(_ams.lockid); + LOCK lock(_ams.lockid); return _amsc_spy_last_message(buffer,size,from,facility,tlen); } int amsc_test_message (void) { CheckInitialization(); - RTL::Lock lock(_ams.lockid); + LOCK lock(_ams.lockid); return _amsc_test_message(); } int amsc_declare_alias (const char* name) { CheckInitialization(); - RTL::Lock lock(_ams.lockid); + LOCK lock(_ams.lockid); char full_name [SAFE_NAME_LENGTH]; amsc_full_name (full_name, name, SAFE_NAME_LENGTH, DECNET_STYLE); int status = tan_declare_alias(full_name); @@ -1341,13 +1337,13 @@ static amsentry_t *_amsc_db_find_entry (amsentry_t **db, const char *data) { int amsc_stack_next_message() { CheckInitialization(); - RTL::Lock lock(_ams.lockid); + LOCK lock(_ams.lockid); return _amsc_stack_next_message(&_ams.message_Q); } int amsc_restore_stack(int *cnt) { CheckInitialization(); - RTL::Lock lock(_ams.lockid); + LOCK lock(_ams.lockid); return _amsc_restore_stack(cnt); } @@ -1368,6 +1364,6 @@ static amsentry_t *_amsc_db_find_entry (amsentry_t **db, const char *data) { int amsc_disconnect_task(const char* task) { CheckInitialization(); - RTL::Lock lock(_ams.lockid); + LOCK lock(_ams.lockid); return _amsc_disconnect_task(task); } diff --git a/Online/OnlineBase/src/AMS/amsu.cpp b/Online/OnlineBase/src/AMS/amsu.cpp index d219936ae1c936feb48a34ace36f11474601f85f..37ebdddfa05ba495b1eb99a0b352f0b57276b175 100755 --- a/Online/OnlineBase/src/AMS/amsu.cpp +++ b/Online/OnlineBase/src/AMS/amsu.cpp @@ -9,12 +9,15 @@ // Author : M.Frank, B.Jost // //========================================================================== +// C/C++ include files #include <cstdio> #include <cstdlib> #include <cstring> -#include "RTL/que.h" -#include "WT/wtdef.h" -#include "AMS/amsdef.h" + +// Framework include files +#include <RTL/que.h> +#include <WT/wtdef.h> +#include <AMS/amsdef.h> struct amsu_fac_entry : public qentry_t { unsigned int facility; diff --git a/Online/OnlineBase/src/ASIO/NameServer.cpp b/Online/OnlineBase/src/ASIO/NameServer.cpp index 1753f0c5a49025f1591c6d6613bed9e79df602fe..97321cfaeca834808f7594ba30bdcd4419d7213d 100755 --- a/Online/OnlineBase/src/ASIO/NameServer.cpp +++ b/Online/OnlineBase/src/ASIO/NameServer.cpp @@ -11,8 +11,8 @@ //========================================================================== // Framework include files -#include "TAN/TanDB.h" -#include "ASIO/TcpServer.h" +#include <TAN/TanDB.h> +#include <ASIO/TcpServer.h> // C/C++ include files #include <set> diff --git a/Online/OnlineBase/src/ASIO/Socket.cpp b/Online/OnlineBase/src/ASIO/Socket.cpp index f522ae9813d7409e767e3ce08ec7cb4c590488bc..a118860528c6599d53cd8d6e925235f78f325b50 100755 --- a/Online/OnlineBase/src/ASIO/Socket.cpp +++ b/Online/OnlineBase/src/ASIO/Socket.cpp @@ -13,10 +13,10 @@ // System / Boost include files // Framework include files -#include "ASIO/Socket.h" -#include "ASIO/TanInterface.h" -#include "TAN/TanMessage.h" -#include "RTL/rtl.h" +#include <ASIO/Socket.h> +#include <ASIO/TanInterface.h> +#include <TAN/TanMessage.h> +#include <RTL/rtl.h> // C/C++ include files #include <iostream> diff --git a/Online/OnlineBase/src/CPP/AsciiDisplay.cpp b/Online/OnlineBase/src/CPP/AsciiDisplay.cpp index 14f4536893fdee30873df700df0c3626f6a6bc71..75c867112bbbfbf14d61f845bf322180eda882f2 100755 --- a/Online/OnlineBase/src/CPP/AsciiDisplay.cpp +++ b/Online/OnlineBase/src/CPP/AsciiDisplay.cpp @@ -18,8 +18,8 @@ #include <mutex> #include <cstdio> #include <cstdlib> -#include "CPP/AsciiDisplay.h" -#include "WT/wtdef.h" +#include <CPP/AsciiDisplay.h> +#include <WT/wtdef.h> #ifdef _WIN32 #define vsnprintf _vsnprintf @@ -220,8 +220,16 @@ namespace { /// Handle single keyboard interrupt bool AsciiDisplay::handleKeyboard(int key) { - for ( const auto& h : m_genHandlers ) - (*h.call)(m_pasteboard, h.param, key); + bool handled = false; + for ( const auto& h : m_genHandlers ) { + auto ret = (*h.call)(m_pasteboard, h.param, key); + if ( ret ) { + handled = true; + } + } + if ( handled ) { + return true; + } auto i = m_handlers.find(key); if ( i != m_handlers.end() ) { const handler_t& h = (*i).second; diff --git a/Online/OnlineBase/src/MBM/BufferInfo.cpp b/Online/OnlineBase/src/MBM/BufferInfo.cpp index 8fe1ebc9a755aa7ae908eee8fc1d861562c9443a..919fa42ad1f6f4ab9903d8d154164c0bd792f3fa 100755 --- a/Online/OnlineBase/src/MBM/BufferInfo.cpp +++ b/Online/OnlineBase/src/MBM/BufferInfo.cpp @@ -11,11 +11,12 @@ //========================================================================== #define MBM_IMPLEMENTATION -#include "MBM/BufferInfo.h" -#include "MBM/bmstruct.h" -#include "MBM/bmserver.h" -#include "MBM/mepdef.h" -#include "RTL/rtl.h" + +#include <MBM/BufferInfo.h> +#include <MBM/bmstruct.h> +#include <MBM/bmserver.h> +#include <MBM/mepdef.h> +#include <RTL/rtl.h> // C/C++ include files #include <iostream> diff --git a/Online/OnlineBase/src/MBM/DumpBits.cpp b/Online/OnlineBase/src/MBM/DumpBits.cpp index 4eee8d8982664e69d6ddb61a27f6b4f283eed523..51a9151d4aff47d9fc399204dc2bc5949b260989 100755 --- a/Online/OnlineBase/src/MBM/DumpBits.cpp +++ b/Online/OnlineBase/src/MBM/DumpBits.cpp @@ -10,8 +10,9 @@ // //========================================================================== #define MBM_IMPLEMENTATION -#include "MBM/bmstruct.h" -#include "RTL/ConsoleDisplay.h" + +#include <MBM/bmstruct.h> +#include <RTL/ConsoleDisplay.h> namespace { void help() { diff --git a/Online/OnlineBase/src/MBM/Dumper.cpp b/Online/OnlineBase/src/MBM/Dumper.cpp index e37ea367280214ede66bb393e270914a59eac2c1..557537ecb2b8badf4a78a6f4088f7d68648b9d03 100755 --- a/Online/OnlineBase/src/MBM/Dumper.cpp +++ b/Online/OnlineBase/src/MBM/Dumper.cpp @@ -9,10 +9,11 @@ // Author : M.Frank // //========================================================================== + #define MBM_IMPLEMENTATION -#include "MBM/bmstruct.h" -#include "MBM/bmserver.h" -#include "MBM/Manager.h" +#include <MBM/bmstruct.h> +#include <MBM/bmserver.h> +#include <MBM/Manager.h> namespace { const char* state_name(int idx) { diff --git a/Online/OnlineBase/src/MBM/Installer.cpp b/Online/OnlineBase/src/MBM/Installer.cpp index 9fd2f5db88c670661e4a7c7e3f288274ce52972d..46fa4927d140b1d89eecedc63458f671c2c185c0 100755 --- a/Online/OnlineBase/src/MBM/Installer.cpp +++ b/Online/OnlineBase/src/MBM/Installer.cpp @@ -10,11 +10,15 @@ // //========================================================================== #define MBM_IMPLEMENTATION -#include "MBM/bmstruct.h" -#include "MBM/bmserver.h" -#include "MBM/bmmessage.h" + +/// Framework include files +#include <MBM/bmstruct.h> +#include <MBM/bmserver.h> +#include <MBM/bmmessage.h> #include "bm_internals.h" #include "Installer.h" + +/// C/C++ include files #include <stdexcept> namespace { diff --git a/Online/OnlineBase/src/MBM/Installer.h b/Online/OnlineBase/src/MBM/Installer.h index b73efe552d7dbf25c4b59ef9d385749b3818ae1b..271239f007162e6745a31580320acb32eaa6b2f7 100755 --- a/Online/OnlineBase/src/MBM/Installer.h +++ b/Online/OnlineBase/src/MBM/Installer.h @@ -12,7 +12,7 @@ #ifndef _MBM_INSTALLER_H #define _MBM_INSTALLER_H -#include "MBM/Manager.h" +#include <MBM/Manager.h> /* * MBM Namespace declaration diff --git a/Online/OnlineBase/src/MBM/Manager.cpp b/Online/OnlineBase/src/MBM/Manager.cpp index 89fc447d751438beb33c69782c73ac0879b57942..8a20cf4d641627db7578b78bda2d0754122391d1 100755 --- a/Online/OnlineBase/src/MBM/Manager.cpp +++ b/Online/OnlineBase/src/MBM/Manager.cpp @@ -10,9 +10,9 @@ // //========================================================================== #define MBM_IMPLEMENTATION -#include "MBM/bmstruct.h" -#include "MBM/Manager.h" -#include "MBM/bmserver.h" +#include <MBM/bmstruct.h> +#include <MBM/Manager.h> +#include <MBM/bmserver.h> #include "bm_internals.h" #include <stdexcept> diff --git a/Online/OnlineBase/src/MBM/Monitor.cpp b/Online/OnlineBase/src/MBM/Monitor.cpp index f5716e853fca909231e6a680e5253c0629a48a56..e8e658e66eb73b4639d2a5455404e7a24d1aefde 100755 --- a/Online/OnlineBase/src/MBM/Monitor.cpp +++ b/Online/OnlineBase/src/MBM/Monitor.cpp @@ -26,13 +26,13 @@ /* 5 19/01/08 Adaption and cleanup for Linux/WIN32 MF */ /*-----------------------------------------------------------------------*/ #define MBM_IMPLEMENTATION -#include "MBM/Monitor.h" -#include "MBM/bmstruct.h" -#include "MBM/bmserver.h" -#include "MBM/Manager.h" -#include "CPP/Event.h" -#include "CPP/TimeSensor.h" -#include "CPP/Interactor.h" +#include <MBM/Monitor.h> +#include <MBM/bmstruct.h> +#include <MBM/bmserver.h> +#include <MBM/Manager.h> +#include <CPP/Event.h> +#include <CPP/TimeSensor.h> +#include <CPP/Interactor.h> #include "bm_internals.h" #include <sys/time.h> diff --git a/Online/OnlineBase/src/MBM/RemoteMon.cpp b/Online/OnlineBase/src/MBM/RemoteMon.cpp index 996524779d05ee4d0d7a1e189f97cb34419c6c51..61c58b68b350c1ff494cf387527fc7b2d0314683 100755 --- a/Online/OnlineBase/src/MBM/RemoteMon.cpp +++ b/Online/OnlineBase/src/MBM/RemoteMon.cpp @@ -17,14 +17,16 @@ // 0 14/05/07 Initial version MF //========================================================================== #define MBM_IMPLEMENTATION -#include "CPP/XMLStream.h" -#include "MBM/bmstruct.h" -#include "MBM/bmserver.h" -#include "MBM/Manager.h" +#include <CPP/XMLStream.h> +#include <MBM/bmstruct.h> +#include <MBM/bmserver.h> +#include <MBM/Manager.h> +#include <NET/TcpConnection.h> +#include <CPP/EventHandler.h> +#include <WT/wtdef.h> + + #include "bm_internals.h" -#include "NET/TcpConnection.h" -#include "CPP/EventHandler.h" -#include "WT/wtdef.h" #define E_MNF 221 diff --git a/Online/OnlineBase/src/MBM/Requirement.cpp b/Online/OnlineBase/src/MBM/Requirement.cpp index 5d58619ae0ed2e0d4fbccceab9544c38d5c66819..494b15ef1f9beaacf6daf4a9685c0d634bf1f384 100755 --- a/Online/OnlineBase/src/MBM/Requirement.cpp +++ b/Online/OnlineBase/src/MBM/Requirement.cpp @@ -9,8 +9,12 @@ // Author : M.Frank // //========================================================================== -#include "MBM/Requirement.h" -#include "MBM/bmdef.h" + +/// Framework include files +#include <MBM/Requirement.h> +#include <MBM/bmdef.h> + +/// C/C++ include files #include <cctype> #include <cstdio> #include <cstring> diff --git a/Online/OnlineBase/src/MBM/Summary.cpp b/Online/OnlineBase/src/MBM/Summary.cpp index a74a7ba6ccf4a0fa88b6b053ad994771abd9f376..df00ec68ba7a9c3f80d8f63dac796ae28ba801ca 100755 --- a/Online/OnlineBase/src/MBM/Summary.cpp +++ b/Online/OnlineBase/src/MBM/Summary.cpp @@ -10,9 +10,11 @@ // //========================================================================== #define MBM_IMPLEMENTATION -#include "MBM/bmstruct.h" -#include "MBM/Manager.h" -#include "MBM/bmserver.h" + +#include <MBM/bmstruct.h> +#include <MBM/Manager.h> +#include <MBM/bmserver.h> + #include "bm_internals.h" using namespace MBM; diff --git a/Online/OnlineBase/src/MBM/bm_internals.h b/Online/OnlineBase/src/MBM/bm_internals.h index 06c1708a88760a3e06778c92910aee86218a73b3..795389fcdaaa14a9655fdf07191baaebcfffb6bc 100755 --- a/Online/OnlineBase/src/MBM/bm_internals.h +++ b/Online/OnlineBase/src/MBM/bm_internals.h @@ -11,10 +11,12 @@ //========================================================================== #ifndef _MBM_INTERNALS_H #define _MBM_INTERNALS_H -#include "RTL/rtl.h" -#include "RTL/que.h" -#include "RTL/bits.h" -#include "MBM/bmdef.h" + +/// Framework include files +#include <RTL/rtl.h> +#include <RTL/que.h> +#include <RTL/bits.h> +#include <MBM/bmdef.h> #ifdef MBM_IMPLEMENTATION struct BMDESCRIPT; diff --git a/Online/OnlineBase/src/MBM/bm_struct.h b/Online/OnlineBase/src/MBM/bm_struct.h index 8cad7f1e025f8216ee3d5d30f2726d88637315f9..fe80dec7cdbc6e04f61b36e05dd862d098860261 100755 --- a/Online/OnlineBase/src/MBM/bm_struct.h +++ b/Online/OnlineBase/src/MBM/bm_struct.h @@ -9,4 +9,5 @@ // Author : M.Frank // //========================================================================== -#include "MBM/bmstruct.h" +/// Framework include files +#include <MBM/bmstruct.h> diff --git a/Online/OnlineBase/src/MBM/mbm_extract.cpp b/Online/OnlineBase/src/MBM/mbm_extract.cpp index 7e7c50a42589e64ba1dd6ce488263cd1810a7b73..522622645e9eae2b868215298cee9e57838b5744 100644 --- a/Online/OnlineBase/src/MBM/mbm_extract.cpp +++ b/Online/OnlineBase/src/MBM/mbm_extract.cpp @@ -11,9 +11,9 @@ //========================================================================== // Framework include files -#include "RTL/rtl.h" -#include "RTL/Logger.h" -#include "MBM/bmdef.h" +#include <RTL/rtl.h> +#include <RTL/Logger.h> +#include <MBM/bmdef.h> // C/C++ include files #include <cerrno> diff --git a/Online/OnlineBase/src/MBM/mbmlib_asio.cpp b/Online/OnlineBase/src/MBM/mbmlib_asio.cpp index d6084776aa31de110af6e30c33248fec3480d907..1d0f728ae02eadc4c219a0d359026e759f00c05c 100755 --- a/Online/OnlineBase/src/MBM/mbmlib_asio.cpp +++ b/Online/OnlineBase/src/MBM/mbmlib_asio.cpp @@ -11,10 +11,11 @@ //========================================================================== // Framework include files -#include "MBM/bmstruct.h" +#include <MBM/bmstruct.h> +#include <ASIO/TcpServer.h> +#include <ASIO/TanInterface.h> + #include "mbmlib_client.h" -#include "ASIO/TcpServer.h" -#include "ASIO/TanInterface.h" // C/C++ include files #include <iostream> diff --git a/Online/OnlineBase/src/MBM/mbmlib_asio_unix.cpp b/Online/OnlineBase/src/MBM/mbmlib_asio_unix.cpp index 447362184eed25fddc5af8557e7eaee42e6c00df..6cc15c5f72b6ccfc2c81b5500aca1c81a856412f 100755 --- a/Online/OnlineBase/src/MBM/mbmlib_asio_unix.cpp +++ b/Online/OnlineBase/src/MBM/mbmlib_asio_unix.cpp @@ -11,9 +11,9 @@ //========================================================================== // Framework include files -#include "MBM/bmstruct.h" +#include <MBM/bmstruct.h> +#include <ASIO/UnixServer.h> #include "mbmlib_client.h" -#include "ASIO/UnixServer.h" // C/C++ include files #include <iostream> diff --git a/Online/OnlineBase/src/MBM/mbmlib_client.cpp b/Online/OnlineBase/src/MBM/mbmlib_client.cpp index 09fe1f78140bf1c186b9167a80731df84933e95a..459710b56a4fd9433a282bbbee3c11919c179644 100755 --- a/Online/OnlineBase/src/MBM/mbmlib_client.cpp +++ b/Online/OnlineBase/src/MBM/mbmlib_client.cpp @@ -26,13 +26,18 @@ *-----------------------------------------------------------------------*/ #define MBM_IMPLEMENTATION + +/// Framework include files +#include <MBM/bmmessage.h> +#include <MBM/bmstruct.h> +#include <MBM/bmdef.h> + +#include "mbmlib_client.h" + +/// C/C++ include files #include <memory> #include <cerrno> #include <string> -#include "mbmlib_client.h" -#include "MBM/bmmessage.h" -#include "MBM/bmstruct.h" -#include "MBM/bmdef.h" using std::string; diff --git a/Online/OnlineBase/src/MBM/mbmlib_client.h b/Online/OnlineBase/src/MBM/mbmlib_client.h index db1ae06105942f0bae04e5963c584637a35a50a3..14659a44481f27922332ee3fc3763d708724d23c 100644 --- a/Online/OnlineBase/src/MBM/mbmlib_client.h +++ b/Online/OnlineBase/src/MBM/mbmlib_client.h @@ -13,10 +13,10 @@ #define _MBMLIB_CLIENT_H #ifdef MBM_IMPLEMENTATION -#include "RTL/que.h" -#include "RTL/bits.h" -#include "MBM/bmdef.h" -#include "MBM/bmconnection.h" +#include <RTL/que.h> +#include <RTL/bits.h> +#include <MBM/bmdef.h> +#include <MBM/bmconnection.h> #include <mutex> diff --git a/Online/OnlineBase/src/MBM/mbmlib_comm_shm.cpp b/Online/OnlineBase/src/MBM/mbmlib_comm_shm.cpp index f20dfc19be2c5fc0ffacbe14ce1da9eadb1e6ef5..d2ceb019d51b2a5fa022bcd9dda53a8f94726f2a 100644 --- a/Online/OnlineBase/src/MBM/mbmlib_comm_shm.cpp +++ b/Online/OnlineBase/src/MBM/mbmlib_comm_shm.cpp @@ -11,7 +11,7 @@ //========================================================================== // Framework include files -#include "MBM/bmstruct.h" +#include <MBM/bmstruct.h> #include "mbmlib_client.h" // C/C++ include files diff --git a/Online/OnlineBase/src/MBM/mbmlib_fifo.cpp b/Online/OnlineBase/src/MBM/mbmlib_fifo.cpp index bf98c72384d33ceb32cb9f62734c60b8463c14e1..e1a7c9614c8cc6247678eca17ed910398d7db982 100755 --- a/Online/OnlineBase/src/MBM/mbmlib_fifo.cpp +++ b/Online/OnlineBase/src/MBM/mbmlib_fifo.cpp @@ -11,7 +11,7 @@ //========================================================================== // Framework include files -#include "MBM/bmstruct.h" +#include <MBM/bmstruct.h> #include "mbmlib_client.h" // C/C++ include files diff --git a/Online/OnlineBase/src/MBM/mbmlib_msg.cpp b/Online/OnlineBase/src/MBM/mbmlib_msg.cpp index 0d7a349c1e511c83f3f52db3d45a9847f5a01bb1..e082d90d6f78a5e74247c845fbcee2c671733058 100755 --- a/Online/OnlineBase/src/MBM/mbmlib_msg.cpp +++ b/Online/OnlineBase/src/MBM/mbmlib_msg.cpp @@ -9,7 +9,7 @@ // Author : M.Frank // //========================================================================== -#include "MBM/bmmessage.h" +#include <MBM/bmmessage.h> namespace { diff --git a/Online/OnlineBase/src/MBM/mbmlib_server.cpp b/Online/OnlineBase/src/MBM/mbmlib_server.cpp index 0095c7813a77fd7e47be96c82edf192f0746f854..16fe2c14d33ce65328449256cf941f521ed55100 100755 --- a/Online/OnlineBase/src/MBM/mbmlib_server.cpp +++ b/Online/OnlineBase/src/MBM/mbmlib_server.cpp @@ -14,13 +14,13 @@ #define MBM_SERVER_IMPLEMENTATION // Framework include files -#include "RTL/Lock.h" -#include "RTL/strdef.h" -#include "RTL/DoubleLinkedQueue.h" -#include "RTL/DoubleLinkedQueueScan.h" -#include "MBM/bmstruct.h" -#include "MBM/bmserver.h" -#include "MBM/bmmessage.h" +#include <RTL/strdef.h> +#include <RTL/DoubleLinkedQueue.h> +#include <RTL/DoubleLinkedQueueScan.h> +#include <MBM/bmstruct.h> +#include <MBM/bmserver.h> +#include <MBM/bmmessage.h> + #include "bm_internals.h" // C/C++ include files diff --git a/Online/OnlineBase/src/MBM/mbmmon.cpp b/Online/OnlineBase/src/MBM/mbmmon.cpp index 0fb58b544bd2aa55c472a65d7142619f0d62dad5..e5054e5919e3dbd0358f2247eaf314d172e29224 100755 --- a/Online/OnlineBase/src/MBM/mbmmon.cpp +++ b/Online/OnlineBase/src/MBM/mbmmon.cpp @@ -14,9 +14,9 @@ /* ASCII BUFFER MANAGER DISPLAY */ /* */ /*-----------------------------------------------------------------------*/ -#include "RTL/rtl.h" -#include "MBM/Monitor.h" -#include "CPP/AsciiDisplay.h" +#include <RTL/rtl.h> +#include <MBM/Monitor.h> +#include <CPP/AsciiDisplay.h> using namespace SCR; diff --git a/Online/OnlineBase/src/MBM/mbmmon_scr.cpp b/Online/OnlineBase/src/MBM/mbmmon_scr.cpp index 1aeb71255331e0218bd91bd34492d4a1fa63895a..4929e9b8cf958b14a972d40336f4e5d1bca2a93c 100644 --- a/Online/OnlineBase/src/MBM/mbmmon_scr.cpp +++ b/Online/OnlineBase/src/MBM/mbmmon_scr.cpp @@ -14,10 +14,12 @@ /* ASCII BUFFER MANAGER DISPLAY */ /* */ /*-----------------------------------------------------------------------*/ -#include "RTL/rtl.h" -#include "MBM/Monitor.h" -#include "CPP/AsciiDisplay.h" -#include "CPP/TimeSensor.h" + +/// Framework include files +#include <RTL/rtl.h> +#include <MBM/Monitor.h> +#include <CPP/AsciiDisplay.h> +#include <CPP/TimeSensor.h> using namespace std; using namespace SCR; @@ -31,7 +33,7 @@ namespace { char text[132] = {0}; Par() = default; }; - void handle_text(SCR::Pasteboard* pb, void* par, int k) { + int handle_text(SCR::Pasteboard* pb, void* par, int k) { Par* p = (Par*)par; if ( p->disp ) { int len = ::strlen(p->text); @@ -51,7 +53,7 @@ namespace { p->text[0] = 0; p->disp = 0; p->mon->optparse(res.c_str()); - return; + return true; } // CR else if ( k>=32 && k<126 ) { p->text[len] = char(k); @@ -61,9 +63,11 @@ namespace { ::scrc_end_pasteboard_update (pb); ::scrc_fflush (pb); ::scrc_set_cursor(p->disp, 1, len); + return true; } + return false; } - void handle_ctrl_p(SCR::Pasteboard* pb, void* par, int) { + int handle_ctrl_p(SCR::Pasteboard* pb, void* par, int) { Par* p = (Par*)par; ::scrc_begin_pasteboard_update (pb); if ( p->disp == 0 ) { @@ -88,8 +92,9 @@ namespace { ::scrc_end_pasteboard_update (pb); ::scrc_fflush (pb); } + return true; } - void handle_ctrl_h(SCR::Pasteboard* pb, void* par, int) { + int handle_ctrl_h(SCR::Pasteboard* pb, void* par, int) { Par* p = (Par*)par; ::scrc_begin_pasteboard_update (pb); if ( p->help ) { @@ -112,6 +117,7 @@ namespace { } ::scrc_end_pasteboard_update (pb); ::scrc_fflush (pb); + return true; } } diff --git a/Online/OnlineBase/src/NET/DataTransfer.cpp b/Online/OnlineBase/src/NET/DataTransfer.cpp index 5f767f5d70edf4a6b96a4bb37fef4ab1c66e01fa..e44332e6b4d1bfc786597aa216bd32ec6630ab92 100755 --- a/Online/OnlineBase/src/NET/DataTransfer.cpp +++ b/Online/OnlineBase/src/NET/DataTransfer.cpp @@ -11,24 +11,24 @@ //========================================================================== #define DATATRANSFER_INTERNALS +/// Framework include files +#include <RTL/rtl.h> +#include <RTL/que.h> +#include <RTL/time.h> +#include <NET/IOPortManager.h> +#include <NET/DataTransfer.h> +#include <TAN/TanInterface.h> + +/// C/C++ include files +#include <stdexcept> #include <cstdio> #include <cerrno> #include <memory> #include <vector> -#include <map> -#include <stdexcept> -#include "RTL/rtl.h" -#include "RTL/que.h" -#include "RTL/time.h" -#include "NET/defs.h" -#include "NET/IOPortManager.h" -#include "NET/DataTransfer.h" -#include "TAN/TanInterface.h" -//#include "ASIO/TanInterface.h" #include <mutex> +#include <map> + #define LOCK std::lock_guard<std::recursive_mutex> -// #include "RTL/Lock.h" -// #define LOCK RTL::Lock /// one-at-time hash function static unsigned int hash32(const char* key) { @@ -685,4 +685,4 @@ void DataTransfer::net_cancel(NET* net) { if ( net ) net->cancel(); } #define TRANSFERTEST(x) test_socket_net_##x -#include "NET/TransferTest.h" +#include <NET/TransferTest.h> diff --git a/Online/OnlineBase/src/NET/IOPortManager.cpp b/Online/OnlineBase/src/NET/IOPortManager.cpp index 4804f8ad2b57a705a9a1abe42dd40c9b5e815b62..ac734d563835f8387e0f0bc4c005284517e387b9 100755 --- a/Online/OnlineBase/src/NET/IOPortManager.cpp +++ b/Online/OnlineBase/src/NET/IOPortManager.cpp @@ -9,15 +9,16 @@ // Author : M.Frank // //========================================================================== -#include "RTL/rtl.h" -#include "NET/IOPortManager.h" +/// Framework include files +#include <RTL/rtl.h> +#include <NET/IOPortManager.h> + +/// C/C++ include files #include <map> #include <vector> #include <stdexcept> #include <mutex> #define LOCK std::lock_guard<std::recursive_mutex> -// #include "RTL/Lock.h" -// #define LOCK RTL::Lock #ifdef __linux #include <sys/poll.h> @@ -26,7 +27,7 @@ #elif _WIN32 #include <conio.h> -#include "RTL/conioex.h" +#include <RTL/conioex.h> #include <windows.h> #include <io.h> #include <fcntl.h> diff --git a/Online/OnlineBase/src/NET/NetworkChannel.cpp b/Online/OnlineBase/src/NET/NetworkChannel.cpp index c05292140a2e0d57c629360e9cfb963ce754ba9f..767753aca6097ec62f9342e8f31e4bf0fc3e4fcb 100755 --- a/Online/OnlineBase/src/NET/NetworkChannel.cpp +++ b/Online/OnlineBase/src/NET/NetworkChannel.cpp @@ -9,11 +9,14 @@ // Author : M.Frank // //========================================================================== +/// Framework include files +#include <NET/NetworkChannel.h> +#include <RTL/rtl.h> +#include <RTL/QIO.h> + +/// C/C++ include files #include <cstring> #include <cerrno> -#include "NET/NetworkChannel.h" -#include "RTL/rtl.h" -#include "RTL/QIO.h" // ---------------------------------------------------------------------------- // Default constructor diff --git a/Online/OnlineBase/src/NET/TcpConnection.cpp b/Online/OnlineBase/src/NET/TcpConnection.cpp index aeed376ee857886731b478629d97ea143a7e73dc..13b4d7a058732b0c3903ed477af4c7c3692e6534 100755 --- a/Online/OnlineBase/src/NET/TcpConnection.cpp +++ b/Online/OnlineBase/src/NET/TcpConnection.cpp @@ -9,11 +9,14 @@ // Author : M.Frank // //========================================================================== +/// Framework include files +#include <CPP/BasicRequest.h> +#include <NET/TcpConnection.h> + +/// C/C++ include files #include <ctime> #include <cstdio> #include <cstring> -#include "CPP/BasicRequest.h" -#include "NET/TcpConnection.h" inline const char* timestr(void) { time_t curr; diff --git a/Online/OnlineBase/src/NET/TcpNetworkChannel.cpp b/Online/OnlineBase/src/NET/TcpNetworkChannel.cpp index 5f108ef1ee11bd95ab450ea4d378e14620bf8f28..fa88b66427ce333ad8a5dc1c2288aaebe4259ff9 100755 --- a/Online/OnlineBase/src/NET/TcpNetworkChannel.cpp +++ b/Online/OnlineBase/src/NET/TcpNetworkChannel.cpp @@ -9,13 +9,16 @@ // Author : M.Frank // //========================================================================== +/// Framework include files +#include <RTL/rtl.h> +#include <NET/defs.h> +#include <NET/IOPortManager.h> +#include <CPP/EventHandler.h> +#include <NET/TcpNetworkChannel.h> + +/// C/C++ include files #include <cstdio> #include <cstdlib> -#include "RTL/rtl.h" -#include "NET/defs.h" -#include "CPP/EventHandler.h" -#include "NET/TcpNetworkChannel.h" -#include "NET/IOPortManager.h" /// Constructor: initialize network connection for CONNECTOR. TcpNetworkChannel::TcpNetworkChannel() { diff --git a/Online/OnlineBase/src/NET/UdpConnection.cpp b/Online/OnlineBase/src/NET/UdpConnection.cpp index dc6dfd45a889f7a59bc468fc7e993fe926bc3b82..462529df6434c87e9049d0c9e00b50bc4a4e517c 100755 --- a/Online/OnlineBase/src/NET/UdpConnection.cpp +++ b/Online/OnlineBase/src/NET/UdpConnection.cpp @@ -9,11 +9,14 @@ // Author : M.Frank // //========================================================================== +/// Framework include files +#include <NET/UdpConnection.h> +#include <CPP/BasicRequest.h> + +/// C/C++ include files #include <ctime> #include <cstdio> #include <cstring> -#include "NET/UdpConnection.h" -#include "CPP/BasicRequest.h" static inline const char* timestr(void) { time_t curr; diff --git a/Online/OnlineBase/src/NET/UdpNetworkChannel.cpp b/Online/OnlineBase/src/NET/UdpNetworkChannel.cpp index 9a5aed482c66269ed81e532e8039f61db9083c54..cebeaf3d753d6e4c2632fcd46f51f5699096434a 100755 --- a/Online/OnlineBase/src/NET/UdpNetworkChannel.cpp +++ b/Online/OnlineBase/src/NET/UdpNetworkChannel.cpp @@ -9,11 +9,14 @@ // Author : M.Frank // //========================================================================== +/// Framework include files +#include <NET/defs.h> +#include <CPP/EventHandler.h> +#include <NET/IOPortManager.h> +#include <NET/UdpNetworkChannel.h> + +/// C/C++ include files #include <cstdio> -#include "NET/defs.h" -#include "CPP/EventHandler.h" -#include "NET/IOPortManager.h" -#include "NET/UdpNetworkChannel.h" // ---------------------------------------------------------------------------- // Constructor: initialize network connection. diff --git a/Online/OnlineBase/src/PUBAREA/PA.cpp b/Online/OnlineBase/src/PUBAREA/PA.cpp index b069c7c11c21fd78a0d7510a1ea29cbdaa41c5e1..7defa9472418bb77497bda1caf8bd3acd9306e06 100755 --- a/Online/OnlineBase/src/PUBAREA/PA.cpp +++ b/Online/OnlineBase/src/PUBAREA/PA.cpp @@ -8,15 +8,15 @@ #include <cstdarg> #include <stdexcept> #include <cstring> -//#include <process.h> -#include "RTL/rtl.h" -#include "AMS/amsdef.h" -#include "CPP/FormatCnv.h" //...................(A_CPP) Needed for format conversion -#include "PA.h" //............. The pubarea class and structure definitions +/// Framework include files +#include "PA.h" //........... The pubarea class and structure definitions +#include <RTL/rtl.h> +#include <AMS/amsdef.h> +#include <CPP/FormatCnv.h> //...................(A_CPP) Needed for format conversion static char LocalProcess[64] = "\0"; -#include "RTL/rtl.h" +#include <RTL/rtl.h> PubArea::PubArea(const char* name) { m_ptr = 0; //... Pointer to the global section/data module @@ -575,13 +575,13 @@ int PubArea::GetPAfromVMS(const char *Node) { size_t buffersize = PA_SIZE_VMS_DEFAULT; strcpy(source,Node); strcat(source,"::PAGBLSERVER_0\0"); - int status = amsc_send_message("DUMP",4,source,0,0); + int status = ::amsc_send_message("DUMP",4,source,0,0); if ( status != AMS_SUCCESS ) { PubAreaPrint(3,status,"PubArea::GetPAfromVMS: Error sending request " "to VMS node %s. Is the server running ?",Node); return PA_FAILURE; } - status = amsc_get_message(m_remote,&buffersize,source,0,100,0,0,0); + status = ::amsc_get_message(m_remote,&buffersize,source,0,100,0,0,0); if ( status != AMS_SUCCESS ) { PubAreaPrint(3,status,"PubArea::GetPAfromVMS: Error receiving data from %s",Node); return PA_FAILURE; diff --git a/Online/OnlineBase/src/PUBAREA/PA.h b/Online/OnlineBase/src/PUBAREA/PA.h index 923541876e15619962a8a203137c998000d95485..85820bbbd23875425eed11bb75b1f44bfa50a338 100755 --- a/Online/OnlineBase/src/PUBAREA/PA.h +++ b/Online/OnlineBase/src/PUBAREA/PA.h @@ -1,15 +1,26 @@ -/* - A_PUBAREA$SRC:PUBAREA.H; - Created : 5-AUG-1996 by A.Pacheco - - This is the file that defines the structures and classes used by the - Publishing Area package (PubArea). Mainly there are three structures: - - PubAreaHeader: Structure of the top header information of the publising area - PubAreaIndex : Structure of the index record for each slot - PubArea : Class handling the publishing area. - -*/ +//========================================================================== +// LHCb Online software suite +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see OnlineSys/LICENSE. +// +// Author : A.Pacheco +// +//========================================================================== +// +// A_PUBAREA$SRC:PUBAREA.H; +// Created : 5-AUG-1996 by A.Pacheco +// +// This is the file that defines the structures and classes used by the +// Publishing Area package (PubArea). Mainly there are three structures: +// +// PubAreaHeader: Structure of the top header information of the publising area +// PubAreaIndex : Structure of the index record for each slot +// PubArea : Class handling the publishing area. +// +//========================================================================== #ifndef _PA_H #define _PA_H @@ -29,9 +40,9 @@ #endif #include <string> //............ Needed for string descriptor handling -#include "CPP/FormatCnv.h" //... Needed for DataStructure conversion OS9 to VMS -#include "CPP/passdef.h" //.......... File containing return code definitions -#include "RTL/rtl.h" +#include <CPP/FormatCnv.h> //... Needed for DataStructure conversion OS9 to VMS +#include <CPP/passdef.h> //.......... File containing return code definitions +#include <RTL/rtl.h> // ********************* // *** PubAreaHeader *** diff --git a/Online/OnlineBase/src/PUBAREA/PubArea.cpp b/Online/OnlineBase/src/PUBAREA/PubArea.cpp index a635a1754ea96167d06be472e84f149d21091c6b..3fc19cdbc7b3e588be073f72211343a9dd8a1e20 100755 --- a/Online/OnlineBase/src/PUBAREA/PubArea.cpp +++ b/Online/OnlineBase/src/PUBAREA/PubArea.cpp @@ -1,6 +1,17 @@ +//========================================================================== +// LHCb Online software suite +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see OnlineSys/LICENSE. +// +// Author : A.Pacheco +// +//========================================================================== #define _pubarea_C #include "PA.h" -#include "CPP/PubArea.h" +#include <CPP/PubArea.h> _PubArea::_PubArea(const char* name ) { obj = new _PubArea::PaObject(name); diff --git a/Online/OnlineBase/src/RTL/ConsoleDisplay.cpp b/Online/OnlineBase/src/RTL/ConsoleDisplay.cpp index f853013934859429a127650dcbd9625e633207d0..1facbf6997852ca0066bc58633b983b753a99752 100755 --- a/Online/OnlineBase/src/RTL/ConsoleDisplay.cpp +++ b/Online/OnlineBase/src/RTL/ConsoleDisplay.cpp @@ -12,8 +12,8 @@ #include <cstdio> #include <cstring> #include <cstdarg> -#include "RTL/rtl.h" -#include "RTL/ConsoleDisplay.h" +#include <RTL/rtl.h> +#include <RTL/ConsoleDisplay.h> using namespace SCR; diff --git a/Online/OnlineBase/src/RTL/FmcLogDevice.cpp b/Online/OnlineBase/src/RTL/FmcLogDevice.cpp index 1f4ad161f5db24617b81e8a07155195a6b58ec16..74f2e0f2fcbc18bb1202da0733fbbd5b2efcb85b 100644 --- a/Online/OnlineBase/src/RTL/FmcLogDevice.cpp +++ b/Online/OnlineBase/src/RTL/FmcLogDevice.cpp @@ -11,7 +11,7 @@ //========================================================================== /// Framework include files -#include "RTL/FmcLogDevice.h" +#include <RTL/FmcLogDevice.h> /// C/C++ include files #include <cerrno> diff --git a/Online/OnlineBase/src/RTL/GlobalSection.cpp b/Online/OnlineBase/src/RTL/GlobalSection.cpp index 91bf553f1a609a3815f42f4c12f8d989923f250c..5756fa5f5171c319d48bd9426e43f4e96c26f15a 100755 --- a/Online/OnlineBase/src/RTL/GlobalSection.cpp +++ b/Online/OnlineBase/src/RTL/GlobalSection.cpp @@ -14,7 +14,7 @@ //========================================================================== // Include files -#include "RTL/GlobalSection.h" +#include <RTL/GlobalSection.h> #include <cerrno> #include <cstdio> diff --git a/Online/OnlineBase/src/RTL/Lock.cpp b/Online/OnlineBase/src/RTL/Lock.cpp deleted file mode 100755 index a93bb3cd64818017e0756b89ca6067105bbe921c..0000000000000000000000000000000000000000 --- a/Online/OnlineBase/src/RTL/Lock.cpp +++ /dev/null @@ -1,51 +0,0 @@ -//========================================================================== -// LHCb Online software suite -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see OnlineSys/LICENSE. -// -//-------------------------------------------------------------------------- -// -// Package : OnlineBase -// -// Author : Markus Frank -//========================================================================== -#include "RTL/Lock.h" -#include <cerrno> -#include <cstdio> - -RTL::Lock::Lock(lib_rtl_lock_t id, bool inverted) : m_mode(inverted), m_id(id) { - m_status = m_mode ? lib_rtl_unlock(m_id) : lib_rtl_lock(m_id); - if ( !lib_rtl_is_success(m_status) ) { - lib_rtl_signal_message(LIB_RTL_OS,"Cannot aquire lock. Status %d",m_status); - errno = m_status; - } -} - -RTL::Lock::~Lock() { - m_status = m_mode ? lib_rtl_lock(m_id) : lib_rtl_unlock(m_id); - if ( !m_status ) { - // throw exception ? - } -} - -/// Create now named lock -int RTL::Lock::create(const char* name, lib_rtl_lock_t& id) { - int status = lib_rtl_create_lock(name, &id); - if (!lib_rtl_is_success(status)) { - lib_rtl_signal_message(LIB_RTL_OS,"Cannot create lock %s. Status %d",name,status); - } - return status; -} - -/// Create now named lock -int RTL::Lock::unlink(lib_rtl_lock_t id) { - int status = lib_rtl_delete_lock(id); - if (!lib_rtl_is_success(status)) { - lib_rtl_signal_message(LIB_RTL_OS,"Cannot delete lock. Status %d",status); - } - return status; -} - diff --git a/Online/OnlineBase/src/RTL/Thread.cpp b/Online/OnlineBase/src/RTL/Thread.cpp deleted file mode 100755 index 0ce980833d432b13aeccf680e8b7202968220194..0000000000000000000000000000000000000000 --- a/Online/OnlineBase/src/RTL/Thread.cpp +++ /dev/null @@ -1,37 +0,0 @@ -//========================================================================== -// LHCb Online software suite -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see OnlineSys/LICENSE. -// -// Author : M.Frank -// -//========================================================================== - -#include "RTL/Thread.h" - -RTL::Thread::Thread() : m_status(1) { - // m_status = lib_rtl_create_thread(m_id); - if ( !lib_rtl_is_success(m_status) ) { - ::lib_rtl_signal_message(LIB_RTL_OS,"Cannot aquire Thread. Status=%d", m_status); - } -} - -RTL::Thread::~Thread() { - // m_status = lib_rtl_unthread(m_id); - if ( !m_status ) { - // throw exception ? - } -} - -/// Create now named Thread -int RTL::Thread::create(const char* name, lib_rtl_thread_t& id) { - int status = 0; //lib_rtl_start_thread(name, &id); - if (!lib_rtl_is_success(status)) { - id = 0; - ::lib_rtl_signal_message(LIB_RTL_OS,"Error in creating Thread %s. Status=%d", name, status); - } - return status; -} diff --git a/Online/OnlineBase/src/RTL/bits.cpp b/Online/OnlineBase/src/RTL/bits.cpp index 00797df003362e5d244b528dff68a205acb3ccf3..190db27ec956d1cb47781c29c848b13b9a589a07 100755 --- a/Online/OnlineBase/src/RTL/bits.cpp +++ b/Online/OnlineBase/src/RTL/bits.cpp @@ -9,8 +9,8 @@ // Author : M.Frank // //========================================================================== -#include "RTL/rtl.h" -#include "RTL/bits.h" +#include <RTL/rtl.h> +#include <RTL/bits.h> #include <cstdio> #include <cstdlib> #include <cstring> diff --git a/Online/OnlineBase/src/RTL/bits2.cpp b/Online/OnlineBase/src/RTL/bits2.cpp index ec728963be28fe81ad918852b1f9f242465e7e11..af24f04a95108ee7a4c6081fdbde124ff03120fc 100644 --- a/Online/OnlineBase/src/RTL/bits2.cpp +++ b/Online/OnlineBase/src/RTL/bits2.cpp @@ -15,8 +15,8 @@ #include <cstdlib> #include <cstring> #include <strings.h> -#include "RTL/rtl.h" -#include "RTL/bits.h" +#include <RTL/rtl.h> +#include <RTL/bits.h> #define BITS_PER_BYTE 8 int BF_count2(const char* base,int bf_size,int* pos,int* size); diff --git a/Online/OnlineBase/src/TAN/TanDB.cpp b/Online/OnlineBase/src/TAN/TanDB.cpp index 923ba8ba638e3f4c61802f56e3edc28562e93d4d..3b185836c3ce2a0856341d92c7b87983bc60052f 100755 --- a/Online/OnlineBase/src/TAN/TanDB.cpp +++ b/Online/OnlineBase/src/TAN/TanDB.cpp @@ -15,19 +15,20 @@ #define _TanDB_C_ -#include <cstdio> -#include <cstdlib> -#include <cstring> -#include <vector> +/// C/C++ include files +#include <cstdio> +#include <cstdlib> +#include <cstring> +#include <vector> -#include <NET/defs.h> -#include <CPP/PubArea.h> -#include <CPP/XMLStream.h> -#include <TAN/TanDB.h> -#include <TAN/TanErrno.h> -#include <RTL/rtl.h> -#include <RTL/Lock.h> +#include <NET/defs.h> +#include <CPP/PubArea.h> +#include <CPP/XMLStream.h> +#include <TAN/TanDB.h> +#include <TAN/TanErrno.h> +#include <RTL/rtl.h> +#define LOCK std::lock_guard<std::mutex> #define NAMESERVICE_PUBAREA_SIZE ((int)(sizeof(TanPaSlot)+sizeof(TanPaSlot)/2)) #define _PreviousEntry(x) (qentry_t*)((char*)(x) + (long)(x)->prev) @@ -133,7 +134,7 @@ extern "C" int tandb_free_port (TanDataBase::Entry* ce) { // M.Frank // ---------------------------------------------------------------------------- TanDataBase::TanDataBase(const char* pa_name) - : m_data(0), m_lock(0), m_error(0) + : m_data(0), m_error(0) { const char* pan = pa_name && ::strlen(pa_name)>0 ? pa_name : NAMESERVICE_PUBAREA_NAME; PubArea Pa(pan); @@ -157,11 +158,6 @@ TanDataBase::TanDataBase(const char* pa_name) } m_error = TAN_SS_SUCCESS; m_data = (TanPaSlot*)slot; -#ifdef WIN32 - status = ::lib_rtl_create_lock ("TANDB", &m_lock); -#else - status = ::lib_rtl_create_lock2(&m_data->_semaphore, &m_lock, true); -#endif if ( !::lib_rtl_is_success(status) ) { ::lib_rtl_output(LIB_RTL_ERROR,"Error creating TANDB lock!\n"); } @@ -171,7 +167,6 @@ TanDataBase::TanDataBase(const char* pa_name) // M.Frank // ---------------------------------------------------------------------------- TanDataBase::~TanDataBase() { - if ( m_lock ) lib_rtl_delete_lock(m_lock); } // ---------------------------------------------------------------------------- // Create the database @@ -226,7 +221,7 @@ TanDataBase& TanDataBase::Instance(const char* pa_name) { // M.Frank // ---------------------------------------------------------------------------- NetworkChannel::Port TanDataBase::findPort ( const TanMessage& msg ) { - RTL::Lock lock(m_lock); + LOCK lock(m_lock); Entry *e = _findEntry ( msg._Name() ); return (e && e->m_dead == 0) ? e->m_port : 0; } @@ -236,11 +231,11 @@ NetworkChannel::Port TanDataBase::findPort ( const TanMessage& msg ) { // M.Frank // ---------------------------------------------------------------------------- int TanDataBase::declarePort ( Entry* ce, u_short port) { - RTL::Lock lock(m_lock); + LOCK lock(m_lock); return _declarePort(ce, port); } int TanDataBase::_declarePort ( Entry* ce, u_short port) { - RTL::Lock lock(m_lock); + LOCK lock(m_lock); int index; if(m_data->_ports >= (TanPaSlot::NumEntries-1)) { // JUST TO AVOID FILLING THE TABLE ... @@ -272,7 +267,7 @@ int TanDataBase::_declarePort ( Entry* ce, u_short port) { // M.Frank // ---------------------------------------------------------------------------- NetworkChannel::Port TanDataBase::allocatePort ( Entry* ce) { - RTL::Lock lock(m_lock); + LOCK lock(m_lock); return _allocatePort(ce); } NetworkChannel::Port TanDataBase::_allocatePort ( Entry* ce) { @@ -306,7 +301,7 @@ NetworkChannel::Port TanDataBase::_allocatePort ( Entry* ce) { // M.Frank // ---------------------------------------------------------------------------- int TanDataBase::freePort ( Entry* e) { - RTL::Lock lock(m_lock); + LOCK lock(m_lock); return _freePort(e); } int TanDataBase::_freePort (Entry* e) { @@ -330,7 +325,7 @@ int TanDataBase::_freePort (Entry* e) { // M.Frank // ---------------------------------------------------------------------------- int TanDataBase::insertAlias ( Entry *ce ) { - RTL::Lock lock(m_lock); + LOCK lock(m_lock); Entry *e = _findEntry ( ce->m_msg.m_name ); if ( e != 0 ) { // CHECK IF ENTRY ALREADY EXISTS m_error = TAN_SS_DUPLNAM; @@ -356,7 +351,7 @@ int TanDataBase::insertAlias ( Entry *ce ) { // M.Frank // ---------------------------------------------------------------------------- int TanDataBase::removeAlias ( Entry *e ) { - RTL::Lock lock(m_lock); + LOCK lock(m_lock); Entry *db = _findEntry ( e->m_msg.m_name ); if ( db == 0 ) { // CHECK IF ENTRY ALREADY EXISTS m_error = TAN_SS_ENTNOTALLOC; @@ -373,7 +368,7 @@ int TanDataBase::removeAlias ( Entry *e ) { // M.Frank // ---------------------------------------------------------------------------- TanDataBase::Entry* TanDataBase::AllocateEntry ( NetworkChannel::Channel chan ) { - RTL::Lock lock(m_lock); + LOCK lock(m_lock); return _allocateEntry(chan); } @@ -423,7 +418,7 @@ int TanDataBase::_freeEntry (TanDataBase::Entry* e) { // M.Frank // ---------------------------------------------------------------------------- TanDataBase::Entry* TanDataBase::FindEntry( const char* proc_name) { - RTL::Lock lock(m_lock); + LOCK lock(m_lock); return _findEntry(proc_name); } TanDataBase::Entry* TanDataBase::_findEntry( const char* proc_name) { @@ -445,7 +440,7 @@ TanDataBase::Entry* TanDataBase::_findEntry( const char* proc_name) { } void TanDataBase::entriesMarkedDead(std::vector<Entry*>& ents) { - RTL::Lock lock(m_lock); + LOCK lock(m_lock); qentry_t *e = (qentry_t*)&m_data->_name_head; for ( Entry* a = (Entry*)_NextEntry(e), *last = 0; a != (Entry*) e && a != 0 && a != last; @@ -458,7 +453,7 @@ void TanDataBase::entriesMarkedDead(std::vector<Entry*>& ents) { } void TanDataBase::entriesByFD(int chan, std::vector<Entry*>& ents) { - RTL::Lock lock(m_lock); + LOCK lock(m_lock); qentry_t *e = (qentry_t*)&m_data->_name_head; for ( Entry* a = (Entry*)_NextEntry(e), *last = 0; a != (Entry*) e && a != 0 && a != last; @@ -477,7 +472,7 @@ void TanDataBase::entriesByFD(int chan, std::vector<Entry*>& ents) { // M.Frank // ---------------------------------------------------------------------------- TanDataBase::Entry* TanDataBase::FindEntry( NetworkChannel::Channel chan ) { - RTL::Lock lock(m_lock); + LOCK lock(m_lock); return _findEntry(chan); } TanDataBase::Entry* TanDataBase::_findEntry( NetworkChannel::Channel chan ) { @@ -500,7 +495,7 @@ TanDataBase::Entry* TanDataBase::_findEntry( NetworkChannel::Channel chan ) { // M.Frank // ---------------------------------------------------------------------------- NetworkChannel::Port TanDataBase::findPort(Entry *e) { - RTL::Lock lock(m_lock); + LOCK lock(m_lock); return _findPort(e); } NetworkChannel::Port TanDataBase::_findPort(Entry *e) { @@ -515,7 +510,7 @@ NetworkChannel::Port TanDataBase::_findPort(Entry *e) { // M.Frank // ---------------------------------------------------------------------------- int TanDataBase::Close (TanDataBase::Entry *ce) { - RTL::Lock lock(m_lock); + LOCK lock(m_lock); return (ce->m_port_flag) ? _freePort (ce) : _freeEntry(ce); } // ---------------------------------------------------------------------------- diff --git a/Online/OnlineKernel/dict/dictionary.h b/Online/OnlineKernel/dict/dictionary.h index 1f288d316e7255727d3f718dbd035a164d3c2d7f..276c0bfcc9d99a119ff20b8d9e8eabe83b3f5215 100755 --- a/Online/OnlineKernel/dict/dictionary.h +++ b/Online/OnlineKernel/dict/dictionary.h @@ -32,30 +32,28 @@ #include <ctime> #include <map> #include <vector> -#include "WT/wtdef.h" -//#include "MBM/bmstruct.h" -#include "MBM/bmdef.h" -#include "RTL/rtl.h" -#include "RTL/que.h" -#include "RTL/bits.h" -#include "RTL/Lock.h" -#include "RTL/Thread.h" -#include "RTL/GlobalSection.h" -#include "AMS/amsdef.h" -#include "NET/DataTransfer.h" -#include "NET/IOPortManager.h" -#include "NET/NetworkChannel.h" -#include "NET/NetworkConnection.h" -#include "NET/TcpNetworkChannel.h" -#include "NET/TcpConnection.h" -#include "NET/UdpNetworkChannel.h" -#include "NET/UdpConnection.h" -#include "SCR/scr.h" -#include "CPP/IocSensor.h" -#include "CPP/AmsSensor.h" -#include "CPP/TimeSensor.h" -#include "CPP/Interactor.h" -#include "CPP/Event.h" + +#include <WT/wtdef.h> +#include <MBM/bmdef.h> +#include <RTL/rtl.h> +#include <RTL/que.h> +#include <RTL/bits.h> +#include <RTL/GlobalSection.h> +#include <AMS/amsdef.h> +#include <NET/DataTransfer.h> +#include <NET/IOPortManager.h> +#include <NET/NetworkChannel.h> +#include <NET/NetworkConnection.h> +#include <NET/TcpNetworkChannel.h> +#include <NET/TcpConnection.h> +#include <NET/UdpNetworkChannel.h> +#include <NET/UdpConnection.h> +#include <SCR/scr.h> +#include <CPP/IocSensor.h> +#include <CPP/AmsSensor.h> +#include <CPP/TimeSensor.h> +#include <CPP/Interactor.h> +#include <CPP/Event.h> namespace { class Dictionary { diff --git a/Online/PCIE40Data/PCIE40Data/pcie40.h b/Online/PCIE40Data/PCIE40Data/pcie40.h index 261a6c1fc4b77221bff8283a718efcfb74a53e06..bcaa056dedb8644a207f09e141cfdeaea07b4b5e 100644 --- a/Online/PCIE40Data/PCIE40Data/pcie40.h +++ b/Online/PCIE40Data/PCIE40Data/pcie40.h @@ -95,11 +95,11 @@ namespace Online { /// Jump to next data fragment including alignment (CONST) const frontend_data_t *next(int len, std::size_t align) const; /// Start pointer of the data fragment - template <typename T> T* begin() { + template <typename T = uint8_t> T* begin() { return reinterpret_cast<T*>(this); } /// Start pointer of the data fragment (CONST) - template <typename T> const T* begin() const { + template <typename T = uint8_t> const T* begin() const { return reinterpret_cast<const T*>(this); } }; @@ -176,8 +176,12 @@ namespace Online { /// Pointer to the array of bank payload sizes const uint16_t *sizes() const; /// Pointer to the start of the data of the banks + frontend_data_t *data(); + /// Pointer to the start of the data of the banks const frontend_data_t *data() const; /// Access the next fragment in the list + multi_fragment_t* next(); + /// Access the next fragment in the list const multi_fragment_t* next() const; /// Get data by proper type template <typename T> T* as(); @@ -206,6 +210,8 @@ namespace Online { /// Offset of individual MFPs uint32_t fragment_offset(std::size_t which) const; /// Access to individual MFPs + multi_fragment_t* multi_fragment(std::size_t which); + /// Access to individual MFPs (CONST) const multi_fragment_t* multi_fragment(std::size_t which) const; /// Support iterations: Jump to next MEP const mep_header_t* next() const; @@ -536,11 +542,21 @@ namespace Online { } /// Pointer to the start of the data of the Banks + inline frontend_data_t* multi_fragment_t::data() { + return add_ptr<frontend_data_t>(this, this->data_offset()); + } + + /// Pointer to the start of the data of the Banks (CONST) inline const frontend_data_t* multi_fragment_t::data() const { return add_ptr<frontend_data_t>(this, this->data_offset()); } /// Access the next fragment in the list + inline multi_fragment_t *multi_fragment_t::next() { + return add_ptr<multi_fragment_t>(this, this->data_offset() + round_up(this->header.size,4)); + } + + /// Access the next fragment in the list (CONST) inline const multi_fragment_t *multi_fragment_t::next() const { return add_ptr<const multi_fragment_t>(this, this->data_offset() + round_up(this->header.size,4)); } @@ -574,6 +590,11 @@ namespace Online { } /// Access to individual MFPs + inline multi_fragment_t* mep_header_t::multi_fragment(std::size_t which) { + return add_ptr<multi_fragment_t>(this, this->fragment_offset(which)); + } + + /// Access to individual MFPs (CONST) inline const multi_fragment_t* mep_header_t::multi_fragment(std::size_t which) const { return add_ptr<multi_fragment_t>(this, this->fragment_offset(which)); } diff --git a/Online/PyDIM/src/dimmodule.cpp b/Online/PyDIM/src/dimmodule.cpp index 134442cdd989c1bc13cac7fd858fc3704107f317..fbbf1747981cc40286eb1a41fc1873a06eb8f56a 100755 --- a/Online/PyDIM/src/dimmodule.cpp +++ b/Online/PyDIM/src/dimmodule.cpp @@ -38,6 +38,11 @@ extern "C" { #include <Python.h> } +#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 9 +#define PYOBJECT_CALL PyObject_CallObject +#else +#define PYOBJECT_CALL PyEval_CallObject +#endif #include "pydim_utils.cpp" @@ -51,6 +56,7 @@ typedef void* func(int*); /* DIS containers for callbacks*/ /******************************************************************************/ + typedef struct { char *name; char *format; @@ -250,7 +256,7 @@ dim_dis_callbackExitHandler(int* code) { if ( dis_callbackExitHandler_func.func ) { gstate = PyGILState_Ensure(); arg = Py_BuildValue("i", *code); - res = PyEval_CallObject(dis_callbackExitHandler_func.func, arg); + res = PyObject_CallObject(dis_callbackExitHandler_func.func, arg); Py_DECREF(arg); Py_XDECREF(res); PyGILState_Release(gstate); @@ -273,7 +279,7 @@ dim_dis_callbackErrorHandler(int severity, int error_code, char* message) { if (dis_callbackErrorHandler_func.func) { gstate = PyGILState_Ensure(); arg = Py_BuildValue("iis", severity, error_code, message); - res = PyEval_CallObject(dis_callbackErrorHandler_func.func, arg); + res = PyObject_CallObject(dis_callbackErrorHandler_func.func, arg); Py_DECREF(arg); Py_XDECREF(res); PyGILState_Release(gstate); @@ -295,7 +301,7 @@ dim_dis_callbackClientExitHandler(int* tag) { if (dis_callbackClientExitHandler_func.func) { gstate = PyGILState_Ensure(); arg = Py_BuildValue("i", *tag); - res = PyEval_CallObject(dis_callbackClientExitHandler_func.func, arg); + res = PyObject_CallObject(dis_callbackClientExitHandler_func.func, arg); Py_DECREF(arg); Py_XDECREF(res); PyGILState_Release(gstate); @@ -824,7 +830,7 @@ dim_dis_update_service(PyObject* /* self */, PyObject* args) { gstate = PyGILState_Ensure(); arg = Py_BuildValue("(i)", svc->pyTag); free(svc_args); - svc_args = PyEval_CallObject(svc->pyFunc, arg); + svc_args = PyObject_CallObject(svc->pyFunc, arg); Py_DECREF(arg); //Py_DECREF(svc_args); // !!!!! PyGILState_Release(gstate); @@ -1496,7 +1502,7 @@ void _dic_error_user_routine_dummy(int severity, int error_code, char* message) if ( _dic_callback_errorHandler_func.func ) { gstate = PyGILState_Ensure(); arg = Py_BuildValue("iis", severity, error_code, message); - res = PyEval_CallObject(_dic_callback_errorHandler_func.func, arg); + res = PyObject_CallObject(_dic_callback_errorHandler_func.func, arg); Py_DECREF(arg); Py_XDECREF(res); PyGILState_Release(gstate); diff --git a/Online/ROMon/ROMon/NodeStatsCollector.h b/Online/ROMon/ROMon/NodeStatsCollector.h index dbf3ab434de7ca9e915ac5e0f93d2a5d2954b444..ed1a550bfffff54c4b1daf36d35988512b59d9fd 100755 --- a/Online/ROMon/ROMon/NodeStatsCollector.h +++ b/Online/ROMon/ROMon/NodeStatsCollector.h @@ -32,6 +32,7 @@ * ROMon namespace declaration */ namespace ROMon { + // Forward declarations class SysInfo; diff --git a/Online/ROMon/ROMon/NodeStatsPublisher.h b/Online/ROMon/ROMon/NodeStatsPublisher.h index e030f949780dce2599f5f17a8a3493de19a2cbe4..5b08df4481acc7a83687810ce195c7c3882170bb 100755 --- a/Online/ROMon/ROMon/NodeStatsPublisher.h +++ b/Online/ROMon/ROMon/NodeStatsPublisher.h @@ -22,8 +22,7 @@ #define ROMON_NODESTATSPUBLISHER_H 1 // Framework include files -#include "ROMon/ROMonGblBuffer.h" -#include "ROMon/FMCMonListener.h" +#include <ROMon/FMCMonListener.h> /* * ROMon namespace declaration diff --git a/Online/ROMon/ROMon/ROMonAsciiPublish.h b/Online/ROMon/ROMon/ROMonAsciiPublish.h deleted file mode 100755 index 0d39e0f4800bd7782973fe89df9e0039900f5b4d..0000000000000000000000000000000000000000 --- a/Online/ROMon/ROMon/ROMonAsciiPublish.h +++ /dev/null @@ -1,50 +0,0 @@ -//========================================================================== -// LHCb Online software suite -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see OnlineSys/LICENSE. -// -//-------------------------------------------------------------------------- -// ROMon -//-------------------------------------------------------------------------- -// -// Package : ROMon -// -// Description: Readout monitoring in the LHCb experiment -// -// Author : M.Frank -// Created : 29/1/2008 -// -//========================================================================== -#ifndef ROMON_ROMONASCIIPUBLISH_H -#define ROMON_ROMONASCIIPUBLISH_H 1 - -// Framework include files -#include "ROMon/ROMonPublish.h" - -/* - * ROMon namespace declaration - */ -namespace ROMon { - - /**@class ROMonAsciiPublish ROMon.h GaudiOnline/ROMon.h - * - * Readout monitor information publisher to stdout - * - * @author M.Frank - */ - class ROMonAsciiPublish : public ROMonPublish { - public: - /// Standard constructor - ROMonAsciiPublish(int argc , char** argv) : ROMonPublish(argc,argv) {} - /// Default destructor - virtual ~ROMonAsciiPublish() {} - /// Publish the collected information - void publish() override; - }; - -} // End namespace ROMon -#endif /* ROMON_ROMONASCIIPUBLISH_H */ - diff --git a/Online/ROMon/ROMon/ROMonDimPublish.h b/Online/ROMon/ROMon/ROMonDimPublish.h deleted file mode 100755 index c36b5f01dccd4c3e9fdeedad8d388d489d4554b6..0000000000000000000000000000000000000000 --- a/Online/ROMon/ROMon/ROMonDimPublish.h +++ /dev/null @@ -1,53 +0,0 @@ -//========================================================================== -// LHCb Online software suite -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see OnlineSys/LICENSE. -// -//-------------------------------------------------------------------------- -// ROMon -//-------------------------------------------------------------------------- -// -// Package : ROMon -// -// Description: Readout monitoring in the LHCb experiment -// -// Author : M.Frank -// Created : 29/1/2008 -// -//========================================================================== -#ifndef ROMON_ROMONDIMPUBLISH_H -#define ROMON_ROMONDIMPUBLISH_H 1 - -// Framework include files -#include "ROMon/ROMonPublish.h" - -/* - * ROMon namespace declaration - */ -namespace ROMon { - - /**@class ROMonDimPublish ROMon.h GaudiOnline/ROMon.h - * - * Readout monitor server - * - * @author M.Frank - */ - class ROMonDimPublish : public ROMonPublish { - protected: - unsigned int m_service; - static void feedData(void* tag, void** address, int* size, int* first); - public: - /// Standard constructor - ROMonDimPublish(int argc , char** argv); - /// Default destructor - virtual ~ROMonDimPublish(); - /// Publish the collected information - void publish() override; - }; - -} // End namespace ROMon -#endif /* ROMON_ROMONDIMPUBLISH_H */ - diff --git a/Online/ROMon/ROMon/ROMonGblBuffer.h b/Online/ROMon/ROMon/ROMonGblBuffer.h deleted file mode 100755 index d389af2a0c6c437f8b5f94d2e89b86a96d64addc..0000000000000000000000000000000000000000 --- a/Online/ROMon/ROMon/ROMonGblBuffer.h +++ /dev/null @@ -1,86 +0,0 @@ -//========================================================================== -// LHCb Online software suite -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see OnlineSys/LICENSE. -// -//-------------------------------------------------------------------------- -// ROMon -//-------------------------------------------------------------------------- -// -// Package : ROMon -// -// Description: Readout monitoring in the LHCb experiment -// -// Author : M.Frank -// Created : 29/1/2008 -// -//========================================================================== -#ifndef ROMON_ROMONGBLBUFFER_H -#define ROMON_ROMONGBLBUFFER_H 1 - -// C++ include files -#include <string> -// Framework include files -#include "RTL/rtl.h" - -/* - * ROMon namespace declaration - */ -namespace ROMon { - - /**@class ROMonGblBuffer ROMonGblBuffer.h ROMon/ROMonGblBuffer.h - * - * Global section buffer to store monitoring information. - * - * @author M.Frank - */ - class ROMonGblBuffer { - private: - lib_rtl_gbl_t m_gbl; - protected: - int m_delay; - int m_print; - bool m_verbose; - bool m_mapOnly; - lib_rtl_lock_t m_lock; - std::string m_section_name; - size_t m_section_size; - - public: - /// Standard constructor - ROMonGblBuffer(); - /// Initializing constructor - ROMonGblBuffer(int argc , char** argv, void (*help_fun)()); - /// Default destructor - virtual ~ROMonGblBuffer(); - /// Initialize the global section - int initialize(); - /// Set section map-only flag - void setMapOnly(bool val) { m_mapOnly=val; } - /// Set section name - void setSectionName(const std::string& val) { m_section_name=val; } - /// Access section name - const std::string& sectionName() const { return m_section_name; } - /// Set section size in KBytes - void setSectionSize(int val) { m_section_size=val*1024; } - /// Access section name in Bytes - size_t sectionSize() const { return m_section_size; } - /// Access to shared memory data buffer - void* data() const; - /// Help printout in case of -h /? or wrong arguments - static void help(); - }; - - struct ROMonGBLData { -#ifndef _WIN32 - sem_t lock; -#endif - char data[4]; - }; - -} // End namespace ROMon -#endif /* ROMON_ROMONGBLBUFFER_H */ - diff --git a/Online/ROMon/ROMon/ROMonNodeCollector.h b/Online/ROMon/ROMon/ROMonNodeCollector.h deleted file mode 100755 index 22c703254b9a22b8064f7544ee3101df054f6a01..0000000000000000000000000000000000000000 --- a/Online/ROMon/ROMon/ROMonNodeCollector.h +++ /dev/null @@ -1,55 +0,0 @@ -//========================================================================== -// LHCb Online software suite -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see OnlineSys/LICENSE. -// -//-------------------------------------------------------------------------- -// ROMon -//-------------------------------------------------------------------------- -// -// Package : ROMon -// -// Description: Readout monitoring in the LHCb experiment -// -// Author : M.Frank -// Created : 29/1/2008 -// -//========================================================================== -#ifndef ROMON_ROMONNODECOLLECTOR_H -#define ROMON_ROMONNODECOLLECTOR_H 1 - -// Framework include files -#include "ROMon/ROMonGblBuffer.h" -#include "ROMon/RODimNodeListener.h" - -/* - * ROMon namespace declaration - */ -namespace ROMon { - - /**@class ROMonNodeCollector ROMon.h GaudiOnline/ROMon.h - * - * Readout monitor DIM server for a single node - * - * @author M.Frank - */ - class ROMonNodeCollector : public ROMonGblBuffer { - protected: - RODimNodeListener m_info; - - public: - /// Standard constructor - ROMonNodeCollector(int argc, char** argv); - /// Default destructor - virtual ~ROMonNodeCollector() {} - /// Start monitoring activity - virtual int monitor(); - /// Help printout in case of -h /? or wrong arguments - static void help(); - }; -} // End namespace ROMon -#endif /* ROMON_ROMONNODECOLLECTOR_H */ - diff --git a/Online/ROMon/ROMon/ROMonPublish.h b/Online/ROMon/ROMon/ROMonPublish.h deleted file mode 100755 index 125c82ca79458956ce0440cfe20179c7fa139590..0000000000000000000000000000000000000000 --- a/Online/ROMon/ROMon/ROMonPublish.h +++ /dev/null @@ -1,53 +0,0 @@ -//========================================================================== -// LHCb Online software suite -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see OnlineSys/LICENSE. -// -//-------------------------------------------------------------------------- -// ROMon -//-------------------------------------------------------------------------- -// -// Package : ROMon -// -// Description: Readout monitoring in the LHCb experiment -// -// Author : M.Frank -// Created : 29/1/2008 -// -//========================================================================== -#ifndef ROMON_ROMONPUBLISH_H -#define ROMON_ROMONPUBLISH_H 1 - -// Framework include files -#include "ROMon/ROMonGblBuffer.h" - -/* - * ROMon namespace declaration - */ -namespace ROMon { - - /**@class ROMonPublish ROMon.h GaudiOnline/ROMon.h - * - * Readout monitor information publisher - * - * @author M.Frank - */ - class ROMonPublish : public ROMonGblBuffer { - public: - /// Standard constructor - ROMonPublish(int argc , char** argv); - /// Default destructor - virtual ~ROMonPublish() {} - /// Help printout in case of -h /? or wrong arguments - static void help(); - /// Start monitoring activity - virtual int monitor(); - /// Publish the collected information - virtual void publish() = 0; - }; -} // End namespace ROMon -#endif /* ROMON_ROMONPUBLISH_H */ - diff --git a/Online/ROMon/ROMon/ROMonTaskCollector.h b/Online/ROMon/ROMon/ROMonTaskCollector.h deleted file mode 100755 index 7fbef0a3158d6b248581e8b04652fe2f4e9142f2..0000000000000000000000000000000000000000 --- a/Online/ROMon/ROMon/ROMonTaskCollector.h +++ /dev/null @@ -1,57 +0,0 @@ -//========================================================================== -// LHCb Online software suite -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see OnlineSys/LICENSE. -// -//-------------------------------------------------------------------------- -// ROMon -//-------------------------------------------------------------------------- -// -// Package : ROMon -// -// Description: Readout monitoring in the LHCb experiment -// -// Author : M.Frank -// Created : 29/1/2008 -// -//========================================================================== -#ifndef ROMON_ROMONTASKCOLLECTOR_H -#define ROMON_ROMONTASKCOLLECTOR_H 1 - -// Framework include files -#include "ROMon/ROMonServer.h" -#include "ROMon/ROMonGblBuffer.h" -#include "ROMon/RODimFSMListener.h" - -/* - * ROMon namespace declaration - */ -namespace ROMon { - - /**@class ROMonTaskCollector ROMon.h GaudiOnline/ROMon.h - * - * Readout monitor DIM server for a single node - * - * @author M.Frank - */ - class ROMonTaskCollector : public ROMonGblBuffer { - protected: - ROMonServer m_mbmInfo; - RODimFSMListener m_fsmInfo; - - public: - /// Standard constructor - ROMonTaskCollector(int argc, char** argv); - /// Default destructor - virtual ~ROMonTaskCollector() {} - /// Start monitoring activity - virtual int monitor(); - /// Help printout in case of -h /? or wrong arguments - static void help(); - }; -} // End namespace ROMon -#endif /* ROMON_ROMONTASKCOLLECTOR_H */ - diff --git a/Online/ROMon/src/CPUMon.cpp b/Online/ROMon/src/CPUMon.cpp index 3c8cb32a8237ca1fb1d6f3214055df830642848a..c5d71c512ffb6f0f706a2c845a2e6b974bd424fe 100755 --- a/Online/ROMon/src/CPUMon.cpp +++ b/Online/ROMon/src/CPUMon.cpp @@ -12,13 +12,17 @@ // // Author : Markus Frank //========================================================================== + +/// C/C++ include files #include <cstring> #include <cstdio> #include <cstdlib> #include <iomanip> + +/// Framework include files +#include <ROMon/CPUMon.h> + #include "ROMonDefs.h" -#include "ROMon/CPUMon.h" -#include "ROMon/ROMonGblBuffer.h" using namespace ROMon; using namespace std; diff --git a/Online/ROMon/src/ROMonAsciiPublish.cpp b/Online/ROMon/src/ROMonAsciiPublish.cpp deleted file mode 100755 index 31c259ed8c42837eaba2395bc531c6110f9f7adf..0000000000000000000000000000000000000000 --- a/Online/ROMon/src/ROMonAsciiPublish.cpp +++ /dev/null @@ -1,58 +0,0 @@ -//========================================================================== -// LHCb Online software suite -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see OnlineSys/LICENSE. -// -//========================================================================== -// ROMon -//-------------------------------------------------------------------------- -// -// Package : ROMon -// -// Description: Readout monitoring in the LHCb experiment -// -// Author : M.Frank -// Created : 29/1/2008 -// -//========================================================================== - -// Framework includes -#define MBM_IMPLEMENTATION -#include "ROMonDefs.h" -#include "ROMon/ROMonOstream.h" -#include "ROMon/ROMonGblBuffer.h" -#include "ROMon/ROMonAsciiPublish.h" - -// C/C++ include files -#include <sstream> - -using namespace ROMon; -using namespace std; - -/// Publish the collected information -void ROMonAsciiPublish::publish() { - stringstream str; - ROMonData gbl(data()); - ::lib_rtl_output(LIB_RTL_ALWAYS,"======================== %s ========================",::lib_rtl_timestr()); - switch(gbl.type()) { - case Node::TYPE: - str << *gbl.node; - break; - case Nodeset::TYPE: - str << *gbl.nodeset; - break; - default: - str << "Unknown data type -- cannot be published."; - break; - } - ::lib_rtl_output(LIB_RTL_ALWAYS,"%s",str.str().c_str()); -} - -extern "C" int romon_gbl_dump(int argc, char** argv) { - ROMonAsciiPublish romon(argc,argv); - return romon.monitor(); -} - diff --git a/Online/ROMon/src/ROMonDimPublish.cpp b/Online/ROMon/src/ROMonDimPublish.cpp deleted file mode 100755 index 76b3f86339b3fc033b9297d8712bf02f50f57621..0000000000000000000000000000000000000000 --- a/Online/ROMon/src/ROMonDimPublish.cpp +++ /dev/null @@ -1,116 +0,0 @@ -//========================================================================== -// LHCb Online software suite -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see OnlineSys/LICENSE. -// -//========================================================================== -// ROMon -//-------------------------------------------------------------------------- -// -// Package : ROMon -// -// Description: Readout monitoring in the LHCb experiment -// -// Author : M.Frank -// Created : 29/1/2008 -// -//========================================================================== - -// C++ include files -#include <stdexcept> - -// Framework includes -#include "dim/dic.h" -#include "dim/dis.hxx" -#include "RTL/Lock.h" -#include "RTL/Logger.h" -#define MBM_IMPLEMENTATION -#include "ROMonDefs.h" -#include "ROMon/ROMon.h" -#include "ROMon/CPUMon.h" -#include "ROMon/ROMonDimPublish.h" - -using namespace ROMon; - -/// Standard constructor -ROMonDimPublish::ROMonDimPublish(int argc , char** argv) : ROMonPublish(argc,argv) { - RTL::CLI cli(argc, argv, ROMonPublish::help); - std::string svc; - cli.getopt("publish",1,svc); - if ( !svc.empty() ) { - m_service = ::dis_add_service(svc.c_str(),"C",0,0,feedData,(long)this); - } - else { - ::lib_rtl_output(LIB_RTL_ERROR,"Unknown data type -- cannot be published."); - throw std::runtime_error("Unknown data type and unknwon service name -- cannot be published."); - } -} - -/// Default destructor -ROMonDimPublish::~ROMonDimPublish() { - ::dis_remove_service(m_service); -} - -void ROMonDimPublish::feedData(void* tag, void** buf, int* size, int* first) { - static const char* empty = ""; - ROMonDimPublish* h = *(ROMonDimPublish**)tag; - if ( !(*first) ) { - RTL::Lock lock(h->m_lock); - ROMonData gbl(h->data()); - CPUMonData cpu(h->data()); - *buf = gbl.ptr; - switch(gbl.type()) { - case Node::TYPE: - *size = gbl.node->totalSize; - break; - case Nodeset::TYPE: - *size = gbl.nodeset->length(); - break; - case CPUfarm::TYPE: - *size = cpu.farm->length(); - break; - case ProcFarm::TYPE: - *size = cpu.procFarm->length(); - break; - case NodeStats::TYPE: - *size = cpu.node->length(); - break; - case Connectionset::TYPE: - *size = cpu.connections->length(); - break; - case SubfarmSummary::TYPE: - *size = cpu.subfarmSummary->length(); - break; - default: - *size = 0; - ::lib_rtl_output(LIB_RTL_ERROR,"Unknown data type -- cannot be published."); - return; - } - if ( h->m_verbose ) { - ::lib_rtl_output(LIB_RTL_INFO,"[ROMonDimPublish] Published %d Butes of data @ %p", - *size, *buf); - } - return; - } - *size = 0; - *buf = (void*)empty; -} - -/// Publish the collected information -void ROMonDimPublish::publish() { - /* int nclients = */ ::dis_update_service(m_service); -} - -extern "C" int romon_dimserver(int argc, char** argv) { - RTL::CLI cli(argc, argv, ROMonPublish::help); - std::string svc; - cli.getopt("publish",1,svc); - ROMonDimPublish romon(argc,argv); - DimServer::start(svc.c_str()); - RTL::Logger::print_startup("information SERVER"); - return romon.monitor(); -} - diff --git a/Online/ROMon/src/ROMonGblBuffer.cpp b/Online/ROMon/src/ROMonGblBuffer.cpp deleted file mode 100755 index e818eae20be89e8132af57e5c9e72835f373282b..0000000000000000000000000000000000000000 --- a/Online/ROMon/src/ROMonGblBuffer.cpp +++ /dev/null @@ -1,108 +0,0 @@ -//========================================================================== -// LHCb Online software suite -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see OnlineSys/LICENSE. -// -//-------------------------------------------------------------------------- -// ROMon -//-------------------------------------------------------------------------- -// -// Package : ROMon -// -// Description: Readout monitoring in the LHCb experiment -// -// Author : M.Frank -// Created : 29/1/2008 -// -//========================================================================== - -// Framework includes -#include "ROMonDefs.h" -#include "ROMon/ROMonGblBuffer.h" -#include <stdexcept> - -using namespace ROMon; - -/// Standard constructor -ROMonGblBuffer::ROMonGblBuffer() - : m_gbl(0), m_delay(2000), m_print(0), m_mapOnly(false), m_lock(0), - m_section_name("ROMonitor"), m_section_size(64) -{ -} - -/// Initializing constructor -ROMonGblBuffer::ROMonGblBuffer(int argc, char** argv, void (*help_fun)()) - : m_gbl(0), m_delay(2000), m_print(0), m_lock(0), - m_section_name("ROMonitor"), m_section_size(64) -{ - RTL::CLI cli(argc, argv, help_fun); - cli.getopt("gbl",1,m_section_name); - cli.getopt("size",1,m_section_size); - cli.getopt("delay",1,m_delay); - m_print = cli.getopt("print",1) != 0; - m_mapOnly = cli.getopt("maponly",3) != 0; - m_verbose = cli.getopt("verbose",1) != 0; - m_section_size *= 1024; - initialize(); -} - -/// Initialize the global section -int ROMonGblBuffer::initialize() { - int sc = m_mapOnly - ? ::lib_rtl_map_section(m_section_name.c_str(),m_section_size,&m_gbl) - : ::lib_rtl_create_section(m_section_name.c_str(),m_section_size,&m_gbl); - if ( !lib_rtl_is_success(sc) ) { - std::string typ = (const char*)(m_mapOnly ? "map" : "create"); - std::string err = "Failed to "+typ+" ROMON global section:"+m_section_name; - ::lib_rtl_output(LIB_RTL_ERROR,"%s of size:%d bytes\n",err.c_str(), m_section_size); - throw std::runtime_error(err); - return 0; - } - ::lib_rtl_output(LIB_RTL_VERBOSE,"Global section %s %s successfully.", - m_section_name.c_str(),((const char*)m_mapOnly ? " mapped" : " created")); -#ifdef _WIN32 - sc = ::lib_rtl_create_lock(m_section_name.c_str(),&m_lock); -#else - sc = ::lib_rtl_create_lock2(&((ROMonGBLData*)m_gbl->address)->lock,&m_lock); -#endif - if ( !lib_rtl_is_success(sc) ) { - ::lib_rtl_output(LIB_RTL_ERROR,"Failed to create ROMON global lock:%s\n",m_section_name.c_str()); - return 0; - } - ::lib_rtl_output(LIB_RTL_VERBOSE,"Global section lock %s created successfully.",m_section_name.c_str()); - return 1; -} - -/// Default destructor -ROMonGblBuffer::~ROMonGblBuffer() { - if ( m_lock ) { - ::lib_rtl_cancel_lock(m_lock); - ::lib_rtl_delete_lock(m_lock); - m_lock = 0; - } - if ( m_gbl ) { - m_mapOnly ? ::lib_rtl_unmap_section(m_gbl) : ::lib_rtl_delete_section(m_gbl); - } - m_gbl = 0; -} - -/// Access to shared memory data buffer -void* ROMonGblBuffer::data() const { - if ( m_gbl ) { - return ((ROMonGBLData*)m_gbl->address)->data; - } - return 0; -} - -/// Help printout in case of -h /? or wrong arguments -void ROMonGblBuffer::help() { - ::lib_rtl_output(LIB_RTL_ALWAYS," -g[bl]=<name> Name of shared global section\n"); - ::lib_rtl_output(LIB_RTL_ALWAYS," -s[ize]=<number> Size of the global section in kBytes\n"); - ::lib_rtl_output(LIB_RTL_ALWAYS," -d[elay]=<number> Delay in milliseconds between two updates of the information\n"); - ::lib_rtl_output(LIB_RTL_ALWAYS," -p[rint]=<number> Make printout to stdout\n"); - ::lib_rtl_output(LIB_RTL_ALWAYS," -map[only Only map the global section; do not create it.\n"); - ::lib_rtl_output(LIB_RTL_ALWAYS," -v[erbose] Verbose mode.\n"); -} diff --git a/Online/ROMon/src/ROMonInfoDump.cpp b/Online/ROMon/src/ROMonInfoDump.cpp deleted file mode 100755 index e221319ba07af0a8727a6e5fa20c0f23c7da726e..0000000000000000000000000000000000000000 --- a/Online/ROMon/src/ROMonInfoDump.cpp +++ /dev/null @@ -1,94 +0,0 @@ -//========================================================================== -// LHCb Online software suite -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see OnlineSys/LICENSE. -// -//========================================================================= -// ROMon -//------------------------------------------------------------------------- -// -// Package : ROMon -// -// Description: Readout monitoring in the LHCb experiment -// -// Author : M.Frank -// Created : 29/1/2008 -// -//========================================================================= - -// C++ include files -#include <iostream> -#include <iomanip> -#include <sstream> - -// Framework includes -#include "dim/dic.hxx" -#include "RTL/rtl.h" -#include "RTL/Logger.h" -#define MBM_IMPLEMENTATION -#include "ROMon/ROMon.h" -#include "ROMon/ROMonOstream.h" -#include "ROMon/ROMonPublish.h" -#include "ROMon/ROMonInfoDump.h" -#include "ROMonDefs.h" - -using namespace ROMon; - -/// Standard constructor -ROMonInfoDump::ROMonInfoDump(int argc, char** argv) : m_info(0) { - char def[32]; - std::string svc = "RONodePublish_"+RTL::nodeNameShort(); - RTL::CLI cli(argc, argv, ROMonPublish::help); - cli.getopt("service",1,svc); - ::memset(def,0xFF,sizeof(def)); - m_info = new DimInfo(svc.c_str(),(void*)def,sizeof(def),this); -} - -/// Default destructor -ROMonInfoDump::~ROMonInfoDump() { - if ( m_info ) delete m_info; -} - -/// Help printout in case of -h /? or wrong arguments -void ROMonInfoDump::help() { - ::lib_rtl_output(LIB_RTL_ALWAYS,"romon_dim_dump -opt [-opt]\n"); - ::lib_rtl_output(LIB_RTL_ALWAYS," -s[ervice]=<name> Name of DIM service providing the information\n"); -} - -/// DimInfo overload to process messages -void ROMonInfoDump::infoHandler() { - const char* nam = getInfo()->getName(); - if ( nam ) { - std::stringstream str; - ROMonData data(getInfo()->getData()); - if ( data.ptr && data.type() != -1 ) { - ::lib_rtl_output(LIB_RTL_INFO,"======================== %s ========================", - ::lib_rtl_timestr()); - switch(data.type()) { - case Node::TYPE: - str << *data.node; - break; - case Nodeset::TYPE: - str << *data.nodeset; - break; - default: - str << "Unknown data type -- cannot be published."; - break; - } - ::lib_rtl_output(LIB_RTL_INFO,str.str().c_str()); - } - } -} - - -extern "C" int romon_info_dump(int argc, char** argv) { - ROMonInfoDump romon(argc,argv); - bool do_run = true; - RTL::Logger::print_startup("DUMP"); - while(do_run) ::lib_rtl_sleep(1000); - return 1; -} - diff --git a/Online/ROMon/src/ROMonNodeCollector.cpp b/Online/ROMon/src/ROMonNodeCollector.cpp deleted file mode 100755 index 19077ab878861ff6d5265b46132f40df3ae457dd..0000000000000000000000000000000000000000 --- a/Online/ROMon/src/ROMonNodeCollector.cpp +++ /dev/null @@ -1,110 +0,0 @@ -//========================================================================== -// LHCb Online software suite -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see OnlineSys/LICENSE. -// -//========================================================================== -// ROMon -//-------------------------------------------------------------------------- -// -// Package : ROMon -// -// Description: Readout monitoring in the LHCb experiment -// -// Author : M.Frank -// Created : 29/1/2008 -// -//========================================================================== - -// C++ include files -#include <iostream> -#include <sstream> - -// Framework includes -#include <dim/dic.hxx> -#include <RTL/rtl.h> -#include <RTL/Lock.h> -#include <RTL/Logger.h> -#define MBM_IMPLEMENTATION -#include "ROMonDefs.h" -#include <ROMon/ROMon.h> -#include <ROMon/ROMonOstream.h> -#include <ROMon/ROMonNodeCollector.h> - -using namespace ROMon; - -/// Standard constructor -ROMonNodeCollector::ROMonNodeCollector(int argc, char** argv) - : ROMonGblBuffer(argc,argv,ROMonNodeCollector::help) -{ - std::string match = "*"; - RTL::CLI cli(argc, argv, ROMonNodeCollector::help); - cli.getopt("match",3,match); - m_info.setMatch(match); - m_info.setVerbose(m_verbose); - m_info.start(); -} - -/// Help printout in case of -h /? or wrong arguments -void ROMonNodeCollector::help() { - ::lib_rtl_output(LIB_RTL_ALWAYS,"romon_node_collect -opt [-opt]\n"); - ROMonGblBuffer::help(); -} - -/// Start monitoring activity -int ROMonNodeCollector::monitor() { - ROMonData gbl(data()); - if ( gbl.ptr ) { - typedef RODimNodeListener::Clients Clients; - bool exec = true; - while(exec) { - Nodeset* n = gbl.nodeset; - if ( n ) { // Take GBL lock while updating - RTL::Lock lock(m_lock); - Nodeset::Nodes& nodes = n->reset()->nodes; - Nodeset::Nodes::iterator it = nodes.reset(); - const Clients& cl = m_info.clients(); - ro_get_node_name(n->name,sizeof(n->name)); - n->type = Nodeset::TYPE; - if ( ((char*)it) > gbl.str+m_section_size ) { - ::lib_rtl_output(LIB_RTL_FATAL,"Global section memory too small.....exiting"); - break; - } - else { - DimLock dim_lock; - for(Clients::const_iterator ic = cl.begin(); ic != cl.end(); ++ic) { - typedef RODimNodeListener::Descriptor DSC; - DSC* d = (*ic).second->data<DSC>(); - if ( ((char*)it) > gbl.str+m_section_size ) { - ::lib_rtl_output(LIB_RTL_FATAL,"Global section memory too small.....exiting"); - break; - } - ::memcpy(it,d->data,d->actual); - it = nodes.add(it); - } - } - } - if ( m_print ) { - std::stringstream str; - ::lib_rtl_output(LIB_RTL_INFO,"======================== %s ========================", - ::lib_rtl_timestr()); - str << *n; - ::lib_rtl_output(LIB_RTL_INFO,"%s",str.str().c_str()); - } - ::lib_rtl_sleep(m_delay); - } - return 1; - } - ::lib_rtl_output(LIB_RTL_INFO,"ROMon gbl %s invalid....exiting",sectionName().c_str()); - return 0; -} - -extern "C" int romon_node_collect(int argc, char** argv) { - ROMonNodeCollector romon(argc,argv); - RTL::Logger::print_startup("information NODE COLLECTOR"); - return romon.monitor(); -} - diff --git a/Online/ROMon/src/ROMonPublish.cpp b/Online/ROMon/src/ROMonPublish.cpp deleted file mode 100755 index 94380f4d1422e3ae2848314c53c3a0044a55cdcc..0000000000000000000000000000000000000000 --- a/Online/ROMon/src/ROMonPublish.cpp +++ /dev/null @@ -1,50 +0,0 @@ -//========================================================================== -// LHCb Online software suite -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see OnlineSys/LICENSE. -// -//========================================================================== -// ROMon -//-------------------------------------------------------------------------- -// -// Package : ROMon -// -// Description: Readout monitoring in the LHCb experiment -// -// Author : M.Frank -// Created : 29/1/2008 -// -//========================================================================== - -// Framework includes -#include "dim/dic.h" -#include "ROMon/ROMonPublish.h" - -using namespace ROMon; - - -/// Standard constructor -ROMonPublish::ROMonPublish(int argc, char** argv) - : ROMonGblBuffer(argc,argv,ROMonPublish::help) -{ -} - -/// Help callback -void ROMonPublish::help() { - ::lib_rtl_output(LIB_RTL_ALWAYS,"romon_gbl_dump -opt [-opt]\n"); - ROMonGblBuffer::help(); -} - -/// Start monitoring activity -int ROMonPublish::monitor() { - bool exec = true; - while(exec) { - publish(); - ::lib_rtl_sleep(m_delay); - } - return 1; -} - diff --git a/Online/ROMon/src/ROMonTaskCollector.cpp b/Online/ROMon/src/ROMonTaskCollector.cpp deleted file mode 100755 index 3a2c56c3b8ece505feec8cf81a62b2ddea8c2d6f..0000000000000000000000000000000000000000 --- a/Online/ROMon/src/ROMonTaskCollector.cpp +++ /dev/null @@ -1,110 +0,0 @@ -//========================================================================== -// LHCb Online software suite -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see OnlineSys/LICENSE. -// -//-------------------------------------------------------------------------- -// ROMon -//-------------------------------------------------------------------------- -// -// Package : ROMon -// -// Description: Readout monitoring in the LHCb experiment -// -// Author : M.Frank -// Created : 29/1/2008 -// -//========================================================================== - -// Framework includes -#include <dim/dic.hxx> -#include <dim/dis.hxx> -#include <RTL/rtl.h> -#include <RTL/Lock.h> -#include <RTL/Logger.h> -#define MBM_IMPLEMENTATION -#include "ROMonDefs.h" -#include <ROMon/ROMonOstream.h> -#include <ROMon/ROMonTaskCollector.h> - -// C/C++ include files -#include <iostream> - -using namespace ROMon; -using namespace std; - -/// Standard constructor -ROMonTaskCollector::ROMonTaskCollector(int argc, char** argv) - : ROMonGblBuffer(argc,argv,ROMonTaskCollector::help), m_mbmInfo(0), m_fsmInfo() -{ - m_fsmInfo.setVerbose(m_verbose); - m_fsmInfo.start(); -} - -/// Help printout in case of -h /? or wrong arguments -void ROMonTaskCollector::help() { - ::lib_rtl_output(LIB_RTL_ALWAYS,"romon_collect -opt [-opt]\n"); - ROMonGblBuffer::help(); - ::lib_rtl_output(LIB_RTL_ALWAYS," -verbose Make printouts to stdout.\n"); -} - -/// Start monitoring activity -int ROMonTaskCollector::monitor() { - ROMonData gbl(data()); - if ( gbl.ptr ) { - typedef RODimFSMListener::Clients Clients; - bool exec = true; - while(exec) { - if ( gbl.node ) { // Take GBL lock while updating - RTL::Lock lock(m_lock); - m_mbmInfo.handle(gbl.node, m_section_size); - Node::Tasks* tasks = gbl.node->tasks(); - Node::Tasks::iterator it = tasks->reset(); - const Clients& cl = m_fsmInfo.clients(); - gbl.node->type = Node::TYPE; - if ( ((char*)it) > gbl.str+m_section_size ) { - ::lib_rtl_output(LIB_RTL_ERROR,"Global section memory too small.....exiting"); - break; - } - else { - ::dim_lock(); - for(Clients::const_iterator ic = cl.begin(); ic != cl.end(); ++ic) { - const FSMTask* t = (*ic).second->data<FSMTask>(); - if ( ((char*)it) > gbl.str+m_section_size ) { - ::lib_rtl_output(LIB_RTL_ERROR,"Global section memory too small.....exiting"); - ::dim_unlock(); - break; - } - if ( t->processID != -1 ) { - ::memcpy(it,t,sizeof(FSMTask)); - it = tasks->add(it); - } - } - ::dim_unlock(); - gbl.node->fixup(); - } - } - if ( m_print ) { - stringstream str; - ::lib_rtl_output(LIB_RTL_ALWAYS,"======================== %s %s", - ::lib_rtl_timestr(), "========================"); - str << *gbl.node; - ::lib_rtl_output(LIB_RTL_ALWAYS,str.str().c_str()); - } - ::lib_rtl_sleep(m_delay); - } - return 1; - } - ::lib_rtl_output(LIB_RTL_ALWAYS,"ROMon gbl invalid....exiting."); - return 0; -} - -extern "C" int romon_collect(int argc, char** argv) { - ROMonTaskCollector romon(argc,argv); - RTL::Logger::print_startup("information COLLECTOR"); - return romon.monitor(); -} - diff --git a/Online/RawBankSizes/RawBankSizes/RawBankSizes.h b/Online/RawBankSizes/RawBankSizes/RawBankSizes.h index c5bb30399b749f7736a0c316af86f15649c48383..e1981d080a9878b77bb3204bd2265a02fb17d816 100755 --- a/Online/RawBankSizes/RawBankSizes/RawBankSizes.h +++ b/Online/RawBankSizes/RawBankSizes/RawBankSizes.h @@ -38,6 +38,13 @@ namespace Online { typedef std::map<std::string,HParam::HistParams*> dethmap; typedef dethmap::iterator dethmiter; typedef std::pair<dethmiter, bool> dethinsrtp; + + typedef Tell1Bank BankHeader; + typedef std::vector<std::pair<const BankHeader*, const void*> > evt_data_t; + + protected: + StatusCode fill_histos(const evt_data_t& data, int runno); + public: /// Standard constructor RawBankSizes(const std::string& name, ISvcLocator* pSvcLocator); @@ -52,11 +59,6 @@ namespace Online { StatusCode finalize () override; protected: - - typedef Tell1Bank BankHeader; - typedef std::vector<std::pair<const BankHeader*, const void*> > evt_data_t; - - StatusCode fill_histos(const evt_data_t& data, int runno); DataObjectReadHandle<evt_data_t> m_rawData{this,"RawData","Banks/RawData"}; std::mutex m_mutex; diff --git a/Online/RawBankSizes/options/EventSizeMon.py b/Online/RawBankSizes/options/EventSizeMon.py new file mode 100644 index 0000000000000000000000000000000000000000..d561cbf4cfcb01c85158841f67c66b1974ddddc8 --- /dev/null +++ b/Online/RawBankSizes/options/EventSizeMon.py @@ -0,0 +1,71 @@ +""" + Online Raw bank size monitoring application configuration + + @author M.Frank +""" +__version__ = "1.0" +__author__ = "Markus Frank <Markus.Frank@cern.ch>" + +import os +import sys +import Configurables +import Gaudi.Configuration as Gaudi +import OnlineEnvBase as OnlineEnv + +import GaudiOnline +from Configurables import Online__FlowManager as FlowManager + + +class EventSizeMon(GaudiOnline.Application): + def __init__(self, outputLevel, partitionName, partitionID, classType): + GaudiOnline.Application.__init__(self, + outputLevel=outputLevel, + partitionName=partitionName, + partitionID=partitionID, + classType=classType) + + def setup_algorithms(self): + import Gaudi.Configuration as Gaudi + import Configurables + input = self.setup_event_input() + monitor = Configurables.Online__EventSize('EventSize') + monitor.RawData = '/Event/Banks/RawData' + monitor.Bins = 100 + monitor.Low = 0.0 + monitor.High = 200e3 + sequence = Gaudi.GaudiSequencer('Processor') + sequence.Members = [input, monitor, self.updateAndReset] + self.app.TopAlg = [sequence] + self.broker.DataProducers = self.app.TopAlg + return self + + def configure(self): + self.setup_fifolog() + self.setup_monitoring('EventSizeMon') + self.setup_mbm_access('Events', True) + self.setup_hive(FlowManager("EventLoop"), 40) + self.updateAndReset.saveHistograms = 1 + self.updateAndReset.saverCycle = 180 + self.updateAndReset.saveSetDir = "/group/online/dataflow/cmtuser/Savesets" + self.updateAndReset.saveSetDir = "/hist/Savesets" + + self.setup_algorithms() + + self.config.burstPrintCount = 30000 + self.config.MBM_numConnections = 1 + self.config.MBM_numEventThreads = 1 + # Mode slection:: synch: 0 async_queued: 1 sync_queued: 2 + self.config.execMode = 0 + self.config.numEventThreads = 1 + # + self.config.MBM_requests = [ + 'EvType=2;TriggerMask=0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF;VetoMask=0,0,0,0;MaskType=ANY;UserType=ONE;Frequency=PERC;Perc=100.0' + ] + print('Setup complete....') + + + +EventSizeMon(outputLevel=OnlineEnv.OutputLevel, + partitionName=OnlineEnv.PartitionName, + partitionID=OnlineEnv.PartitionID, + classType=GaudiOnline.Class1).configure() diff --git a/Online/RawBankSizes/options/RawSizeMon.py b/Online/RawBankSizes/options/RawSizeMon.py index 23ef3555df63b701ed34e6085eb5ec7d34bbb3ec..96fe2a89062aafa56833ff1eb9a3eefb1c2072d1 100644 --- a/Online/RawBankSizes/options/RawSizeMon.py +++ b/Online/RawBankSizes/options/RawSizeMon.py @@ -142,49 +142,32 @@ class RawSizeMon(GaudiOnline.Application): monitor.Calo = (100,0.0,10000.0,0,1024,"Calo") monitor.CaloError = (100,0.0,10000.0,0,1024,"Calo") - self.app.TopAlg = [] input = self.setup_event_input() - self.app.TopAlg.append(input) - self.app.TopAlg.append(monitor) - if hasattr(self,'updateAndReset'): - self.app.TopAlg.append(self.updateAndReset) - self.broker.DataProducers = self.app.TopAlg + sequence = Gaudi.GaudiSequencer('Processor') + sequence.Members = [input, monitor, self.updateAndReset] + self.app.TopAlg = [sequence] + self.broker.DataProducers = self.app.TopAlg return self - application = RawSizeMon(outputLevel=OnlineEnv.OutputLevel, partitionName=OnlineEnv.PartitionName, partitionID=OnlineEnv.PartitionID, classType=GaudiOnline.Class1) # application.setup_fifolog() -application.setup_monitoring() # Must be one of the first statements! +application.setup_monitoring('RawBankSizes') application.setup_mbm_access('Events', True) application.setup_hive(FlowManager("EventLoop"), 40) -application.monSvc.ProgramName = 'RawBankSizes' -application.monSvc.UseDStoreNames = True -application.monSvc.DimUpdateInterval = 1 application.updateAndReset.saveHistograms = 1 -application.updateAndReset.saverCycle = 90 +application.updateAndReset.saverCycle = 300 application.updateAndReset.saveSetDir = "/group/online/dataflow/cmtuser/Savesets" - - +application.updateAndReset.saveSetDir = "/hist/Savesets" +# application.setup_algorithms() - -application.config.burstPrintCount = 30000 -application.config.MBM_numConnections = 1 -application.config.MBM_numEventThreads = 1 -# Mode slection:: synch: 0 async_queued: 1 sync_queued: 2 -application.config.execMode = 1 -application.config.numEventThreads = 1 # +# Mode slection:: synch: 0 async_queued: 1 sync_queued: 2 application.config.execMode = 0 application.config.numEventThreads = 1 # -application.config.MBM_requests = [ - 'EvType=2;TriggerMask=0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF;VetoMask=0,0,0,0;MaskType=ANY;UserType=ONE;Frequency=PERC;Perc=100.0', - 'EvType=1;TriggerMask=0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF;VetoMask=0,0,0,0;MaskType=ANY;UserType=ONE;Frequency=PERC;Perc=100.0' -] -# print('Setup complete....') diff --git a/Online/RawBankSizes/scripts/EventSizeMon.sh b/Online/RawBankSizes/scripts/EventSizeMon.sh new file mode 100755 index 0000000000000000000000000000000000000000..f54de7c8cf3c77d5d1440eecf480df95c9ef709d --- /dev/null +++ b/Online/RawBankSizes/scripts/EventSizeMon.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# +export CMTCONFIG=x86_64_v2-centos7-gcc10-opt; +export CMTCONFIG=x86_64_v2-centos7-gcc10-do0; +# +cd /group/online/dataflow/cmtuser/OnlineRelease; +. setup.${CMTCONFIG}.vars; +. ${FARMCONFIGROOT}/job/createEnvironment.sh $*; +# +setup_options_path MONITORING; +# +exec -a ${UTGID} genPython.exe `which gaudirun.py` ${RAWBANKSIZESROOT}/options/EventSizeMon.py --application=OnlineEvents; diff --git a/Online/RawBankSizes/scripts/RawSizeMon.sh b/Online/RawBankSizes/scripts/RawSizeMon.sh index a109247a0522394af41cfd7f42aea781fd4073ff..4bd78d1d0536d978842014c7d59207035e66491a 100755 --- a/Online/RawBankSizes/scripts/RawSizeMon.sh +++ b/Online/RawBankSizes/scripts/RawSizeMon.sh @@ -1,32 +1,12 @@ #!/bin/bash -export UTGID=${UTGID} -if test -n "${LOGFIFO}"; then - export LOGFIFO=${LOGFIFO}; -fi; -if test -z "${LOGFIFO}" -a -e /dev/shm/logs.dev; then - export LOGFIFO=/dev/shm/logs.dev; -fi; -if [ -r /etc/sysconfig/dim ]; then - . /etc/sysconfig/dim; - if test "`echo $DIM_DNS_NODE | cut -b 1-5`" = "fmc01"; then - DIM_DNS_NODE=`hostname -s`; - fi; - export DIM_DNS_NODE; -fi; # export CMTCONFIG=x86_64_v2-centos7-gcc10-opt; export CMTCONFIG=x86_64_v2-centos7-gcc10-do0; # -. /group/online/dataflow/cmtuser/OnlineRelease/setup.${CMTCONFIG}.vars; +cd /group/online/dataflow/cmtuser/OnlineRelease; +. setup.${CMTCONFIG}.vars; . ${FARMCONFIGROOT}/job/createEnvironment.sh $*; # -export GEN_OPTIONS=/group/online/dataflow/options/${PARTITION}/MONITORING; +setup_options_path MONITORING; # -export ONLINETASKS=/group/online/dataflow/templates; -export INFO_OPTIONS=/group/online/dataflow/options/${PARTITION}/MONITORING/OnlineEnv.opts; -export PREAMBLE_OPTS=${FARMCONFIGROOT}/options/Empty.opts; -export PYTHONPATH=${GEN_OPTIONS}:${PYTHONPATH} -# -# -echo exec -a ${UTGID} genPython.exe `which gaudirun.py` ${RAWBANKSIZESROOT}/options/RawSizeMon.py --application=OnlineEvents; exec -a ${UTGID} genPython.exe `which gaudirun.py` ${RAWBANKSIZESROOT}/options/RawSizeMon.py --application=OnlineEvents; diff --git a/Online/RawBankSizes/scripts/RawSizeONLMon.sh b/Online/RawBankSizes/scripts/RawSizeONLMon.sh index a109247a0522394af41cfd7f42aea781fd4073ff..2b8bb014d803b2cdde527ed103b7a085fd460935 100644 --- a/Online/RawBankSizes/scripts/RawSizeONLMon.sh +++ b/Online/RawBankSizes/scripts/RawSizeONLMon.sh @@ -1,18 +1,4 @@ #!/bin/bash -export UTGID=${UTGID} -if test -n "${LOGFIFO}"; then - export LOGFIFO=${LOGFIFO}; -fi; -if test -z "${LOGFIFO}" -a -e /dev/shm/logs.dev; then - export LOGFIFO=/dev/shm/logs.dev; -fi; -if [ -r /etc/sysconfig/dim ]; then - . /etc/sysconfig/dim; - if test "`echo $DIM_DNS_NODE | cut -b 1-5`" = "fmc01"; then - DIM_DNS_NODE=`hostname -s`; - fi; - export DIM_DNS_NODE; -fi; # export CMTCONFIG=x86_64_v2-centos7-gcc10-opt; export CMTCONFIG=x86_64_v2-centos7-gcc10-do0; @@ -20,13 +6,6 @@ export CMTCONFIG=x86_64_v2-centos7-gcc10-do0; . /group/online/dataflow/cmtuser/OnlineRelease/setup.${CMTCONFIG}.vars; . ${FARMCONFIGROOT}/job/createEnvironment.sh $*; # -export GEN_OPTIONS=/group/online/dataflow/options/${PARTITION}/MONITORING; +`setup_options_pathes MONITORING`; # -export ONLINETASKS=/group/online/dataflow/templates; -export INFO_OPTIONS=/group/online/dataflow/options/${PARTITION}/MONITORING/OnlineEnv.opts; -export PREAMBLE_OPTS=${FARMCONFIGROOT}/options/Empty.opts; -export PYTHONPATH=${GEN_OPTIONS}:${PYTHONPATH} -# -# -echo exec -a ${UTGID} genPython.exe `which gaudirun.py` ${RAWBANKSIZESROOT}/options/RawSizeMon.py --application=OnlineEvents; exec -a ${UTGID} genPython.exe `which gaudirun.py` ${RAWBANKSIZESROOT}/options/RawSizeMon.py --application=OnlineEvents; diff --git a/Online/RawBankSizes/src/EventSize.cpp b/Online/RawBankSizes/src/EventSize.cpp index d52cc2b933a8c2932517d772d38e3b2d45832500..099efecddbd6f1d3f8d114a9aa5d9e5ea1e3fbe5 100644 --- a/Online/RawBankSizes/src/EventSize.cpp +++ b/Online/RawBankSizes/src/EventSize.cpp @@ -15,7 +15,6 @@ // Framework include files #include <Gaudi/Algorithm.h> -#include <GaudiKernel/MsgStream.h> #include <GaudiKernel/IHistogramSvc.h> #include <GaudiKernel/DataObjectHandle.h> #include <Tell1Data/Tell1Bank.h> @@ -38,8 +37,13 @@ namespace Online { private: typedef Tell1Bank BankHeader; typedef std::vector<std::pair<const BankHeader*, const void*> > evt_data_t; - DataObjectReadHandle<evt_data_t> m_rawData{this,"RawData","Banks/RawData"}; + + private: + DataObjectReadHandle<evt_data_t> m_rawData {this,"RawData","Banks/RawData"}; Gaudi::Property<std::string> m_histPath{this,"HistogramPath", "EventSize/TotalSize","Place of histogram"}; + Gaudi::Property<int> m_bins {this,"Bins", 100, "Number of histogram bins"}; + Gaudi::Property<double> m_low {this,"Low", 0.0, "Low edge"}; + Gaudi::Property<double> m_high {this,"High", 200e3, "High edge"}; AIDA::IHistogram1D* m_eveLen = 0; public: @@ -49,7 +53,7 @@ namespace Online { /// Algorithm overload: Initialize the algorithm StatusCode initialize() override { if ( !histoSvc()->findObject(m_histPath, m_eveLen).isSuccess() ) { - m_eveLen = histoSvc()->book(m_histPath, "Total raw event size", 100, 0.0, 200e3); + m_eveLen = histoSvc()->book(m_histPath, "Total raw event size", m_bins, m_low, m_high); declareInfo("EventSize/TotalSize", m_eveLen, m_eveLen->title()); } return StatusCode::SUCCESS; @@ -68,21 +72,19 @@ namespace Online { /// Algorithm overload: Event execution routine StatusCode execute(const EventContext& /* context */ ) const override final { + using namespace std; if ( !m_eveLen ) { - MsgStream err(msgSvc(),name()); - err << MSG::ERROR << "Where the hack did my histogram go?" << endmsg; + error() << "Where the hack did my histogram go?" << endmsg; return StatusCode::FAILURE; } const evt_data_t* event = m_rawData.get(); if ( event ) { - std::size_t total_length = 0; - for( const auto& b : *event ) - total_length += b.first->totalSize(); - m_eveLen->fill(double(total_length), 1.0); + std::size_t len = 0; + for_each(begin(*event),end(*event),[&len](const auto& b) { len += b.first->totalSize(); }); + m_eveLen->fill(double(len), 1.0); return StatusCode::SUCCESS; } - MsgStream err(msgSvc(),name()); - err << MSG::ERROR << "No raw data object found at " << m_rawData << endmsg; + error() << "No raw data object found at " << m_rawData << endmsg; return StatusCode::SUCCESS; // We want to continue! } }; diff --git a/Online/RawBankSizes/src/RawBankSizes.cpp b/Online/RawBankSizes/src/RawBankSizes.cpp index c63ec9c2f563d2c10e89c94a2162d5c88c573e2f..141ea6a705db3562d96fdcce1dd56e1d954ca66c 100644 --- a/Online/RawBankSizes/src/RawBankSizes.cpp +++ b/Online/RawBankSizes/src/RawBankSizes.cpp @@ -74,7 +74,7 @@ RawBankSizes::RawBankSizes( const std::string& name, declareProperty(bname,m_hparams[i]/*,"(0,0.0,0.0,0,-2)"*/); continue; } - ::printf("Warning: RawBankSizes: Unknown bank type: %d\n",i); + warning() << "RawBankSizes: Unknown bank type: " << i << endmsg; } declareProperty("TotEv",m_totevpar/*,"(0,0.0,0.0,0,-2)"*/); declareProperty("HLTRatio",m_HLTratiopar/*,"(0,0.0,0.0,0,-2)"*/); @@ -138,6 +138,7 @@ StatusCode RawBankSizes::initialize() { } Banks[i].nohist = (m_hparams[i].n_bin <= 0); } + std::string title; for(int i = 0 ; i != (int) Tell1Bank::LastType; i++) { int idx = i; if (Banks[i].isError) { @@ -153,10 +154,11 @@ StatusCode RawBankSizes::initialize() { } Banks[i].nbin = m_hparams[i].n_bin; for (int hindx = 0; hindx < HISTPERHIST;hindx++) { + title = Banks[i].name+" Size in Bytes"+titqual[hindx]; Banks[i].h[hindx] = histoSvc()->book( Banks[i].h_name[hindx], - Banks[i].name+" Size in Bytes"+titqual[hindx],m_hparams[i].n_bin, + title, m_hparams[i].n_bin, m_hparams[i].xmin,m_hparams[i].xmax); - declareInfo(Banks[i].h_name[hindx], Banks[i].h[hindx],Banks[i].name+" Size in Bytes"+titqual[hindx]); + declareInfo(Banks[i].h_name[hindx], Banks[i].h[hindx],title); } } else { @@ -164,10 +166,11 @@ StatusCode RawBankSizes::initialize() { } if (!Banks[i].noprofile) { for (int hindx=0; hindx<HISTPERHIST; hindx++) { - Banks[i].p[hindx] = histoSvc()->bookProf( Banks[i].p_name[hindx],Banks[i].name+" Size vs. SourceID"+titqual[hindx], + title = Banks[i].name+" Size vs. SourceID"+titqual[hindx]; + Banks[i].p[hindx] = histoSvc()->bookProf( Banks[i].p_name[hindx], title, m_hparams[idx].s_max-m_hparams[idx].s_min+1, - (float)m_hparams[idx].s_min,(float)m_hparams[idx].s_max); - declareInfo(Banks[i].p_name[hindx], Banks[i].p[hindx],Banks[i].name+" Size vs. SourceID"+titqual[hindx]); + (float)m_hparams[idx].s_min, (float)m_hparams[idx].s_max); + declareInfo(Banks[i].p_name[hindx], Banks[i].p[hindx], title); } } else { @@ -184,19 +187,18 @@ StatusCode RawBankSizes::initialize() { printf("Binwidth for %s not a multiple of 4. %f\n",Banks[0].name.c_str(),m_totsize.binw); } for(int hindx = 0; hindx<HISTPERHIST; hindx++ ) { - h_totev[hindx] = histoSvc()->book("TotSize"+namqual[hindx], - "Total Event Size in Bytes"+titqual[hindx], + title = "Total Event Size in Bytes"+titqual[hindx]; + h_totev[hindx] = histoSvc()->book("TotSize"+namqual[hindx], title, m_totevpar.n_bin, m_totevpar.xmin,m_totevpar.xmax); - declareInfo("TotSize"+namqual[hindx], - h_totev[hindx], - "Total Event Size in Bytes"+titqual[hindx]); - - h_HLTratio[hindx] = histoSvc()->book( "HLTRatio"+namqual[hindx],"Ratio HLT Total Size"+titqual[hindx],m_HLTratiopar.n_bin, + declareInfo("TotSize"+namqual[hindx], h_totev[hindx], title); + title = "Ratio HLT Total Size"+titqual[hindx]; + h_HLTratio[hindx] = histoSvc()->book( "HLTRatio"+namqual[hindx],title,m_HLTratiopar.n_bin, m_HLTratiopar.xmin,m_HLTratiopar.xmax); - declareInfo("HLTRatio"+namqual[hindx], h_HLTratio[hindx],"Ratio HLT Total Size"+titqual[hindx]); - p_banks[hindx] = histoSvc()->bookProf("Banksp"+namqual[hindx],"Bank Size vs. Bank Number"+titqual[hindx], + declareInfo("HLTRatio"+namqual[hindx], h_HLTratio[hindx],title); + title = "Bank Size vs. Bank Number"+titqual[hindx]; + p_banks[hindx] = histoSvc()->bookProf("Banksp"+namqual[hindx], title, Tell1Bank::LastType+1, -1.0, (float)Tell1Bank::LastType); - declareInfo("Banksp"+namqual[hindx],p_banks[hindx],"Bank Size vs. Bank Number"+titqual[hindx]); + declareInfo("Banksp"+namqual[hindx],p_banks[hindx], title); } for (const auto& j : m_dethparams ) { detbmiter bd = m_detectors.find(j.first); @@ -209,12 +211,10 @@ StatusCode RawBankSizes::initialize() { info() << "Binwidth for " << Banks[0].name << " not a multiple of 4. " << bd->second->binw << endmsg; } for (int hindx=0; hindx<HISTPERHIST; hindx++) { - bd->second->h[hindx] = histoSvc()->book("Total_"+j.first+namqual[hindx], - "Total Size for "+j.first+" in Bytes"+titqual[hindx], + title = "Total Size for "+j.first+" in Bytes"+titqual[hindx]; + bd->second->h[hindx] = histoSvc()->book("Total_"+j.first+namqual[hindx], title, j.second->n_bin, j.second->xmin,j.second->xmax); - declareInfo("Total_"+j.first+namqual[hindx], - bd->second->h[hindx], - "Total Size for "+j.first+" in Bytes"+titqual[hindx]); + declareInfo("Total_"+j.first+namqual[hindx], bd->second->h[hindx], title); } } return StatusCode::SUCCESS; @@ -234,8 +234,7 @@ StatusCode RawBankSizes::execute(const EventContext& /* context */) const { const evt_data_t* event = m_rawData.get(); int runno = 100; if ( !event ) { - MsgStream msg(msgSvc(), name()); - msg << MSG::WARNING << "rawEvent not found at location '" << m_rawData << endmsg; + warning() << "Raw data not found at location '" << m_rawData << endmsg; return StatusCode::SUCCESS; } for( const auto& b : *event ) { diff --git a/Online/SmiController/options/MonNode.smi b/Online/SmiController/options/MonNode.smi index f089499adc13f9c9582813f1a85a83c2317bb925..9ea40326c2583371b3a71392db20bdc90d7ad07a 100644 --- a/Online/SmiController/options/MonNode.smi +++ b/Online/SmiController/options/MonNode.smi @@ -351,6 +351,7 @@ class: TOP_Node_CLASS endif state: ERROR !color: FwStateAttention3 + when ( any_in ALLCHILDREN_SETSTATES in_state ERROR ) stay_in_state when ( any_in DEF_SETSTATES in_state {OFFLINE,UNKNOWN} ) move_to NOT_READY when ( any_in CONTROLLER_SETSTATES in_state {OFFLINE,UNKNOWN} ) move_to NOT_READY when ( all_in ALLCHILDREN_SETSTATES in_state READY ) move_to READY diff --git a/Online/SmiController/options/MonNode.sobj b/Online/SmiController/options/MonNode.sobj index 187f203e1bbef6e029d48feb0711c5ba901a75bf..986b783f5f398052ac22c8ebeacf83281c32ad1f 100644 --- a/Online/SmiController/options/MonNode.sobj +++ b/Online/SmiController/options/MonNode.sobj @@ -2409,6 +2409,19 @@ READY *STATE ERROR 0 +*WHEN + ( ANY_IN ALLCHILDREN_SETSTATES IN_STATE ERROR ) + 1 0 + 2 +ALLCHILDREN_SETSTATES +any_in +in_state + 1 +ERROR +do +&NULL + 0 +&THIS_OBJECT *WHEN ( ANY_IN DEF_SETSTATES IN_STATE {OFFLINE,UNKNOWN} ) 1 0 @@ -2420,7 +2433,7 @@ in_state OFFLINE UNKNOWN do -&END_IN_STATE_WHEN0 +&END_IN_STATE_WHEN1 0 &THIS_OBJECT *WHEN @@ -2434,7 +2447,7 @@ in_state OFFLINE UNKNOWN do -&END_IN_STATE_WHEN1 +&END_IN_STATE_WHEN2 0 &THIS_OBJECT *WHEN @@ -2447,7 +2460,7 @@ in_state 1 READY do -&END_IN_STATE_WHEN2 +&END_IN_STATE_WHEN3 0 &THIS_OBJECT *WHEN @@ -2460,7 +2473,7 @@ in_state 1 RUNNING do -&END_IN_STATE_WHEN3 +&END_IN_STATE_WHEN4 0 &THIS_OBJECT *WHEN @@ -2474,7 +2487,7 @@ in_state OFFLINE UNKNOWN do -&END_IN_STATE_WHEN4 +&END_IN_STATE_WHEN5 0 &THIS_OBJECT *ACTION @@ -2720,7 +2733,7 @@ terminate OFFLINE *END_ACTION *ACTION -&END_IN_STATE_WHEN0 +&END_IN_STATE_WHEN1 0 0 *BLOCK 0 0 @@ -2728,7 +2741,7 @@ terminate NOT_READY *END_ACTION *ACTION -&END_IN_STATE_WHEN1 +&END_IN_STATE_WHEN2 0 0 *BLOCK 0 0 @@ -2736,7 +2749,7 @@ terminate NOT_READY *END_ACTION *ACTION -&END_IN_STATE_WHEN2 +&END_IN_STATE_WHEN3 0 0 *BLOCK 0 0 @@ -2744,7 +2757,7 @@ terminate READY *END_ACTION *ACTION -&END_IN_STATE_WHEN3 +&END_IN_STATE_WHEN4 0 0 *BLOCK 0 0 @@ -2752,7 +2765,7 @@ terminate RUNNING *END_ACTION *ACTION -&END_IN_STATE_WHEN4 +&END_IN_STATE_WHEN5 0 0 *BLOCK 0 0 diff --git a/Online/SmiController/scripts/EventProcessor.py b/Online/SmiController/scripts/EventProcessor.py index 3f66dc105b5b3f428276805587f5b9c613f12954..6af0181a7c7396a79694c32ce1781c69bb6113f7 100644 --- a/Online/SmiController/scripts/EventProcessor.py +++ b/Online/SmiController/scripts/EventProcessor.py @@ -22,7 +22,7 @@ application = GaudiOnline.Passthrough(outputLevel=OnlineEnvBase.OutputLevel, partitionID=OnlineEnvBase.PartitionID, classType=GaudiOnline.Class1) application.setup_fifolog() -application.log(GaudiOnline.MSG_ERROR,'+++ OnlineEnv: %s Level:%d',OnlineEnvBase.__file__,OnlineEnvBase.OutputLevel) +application.log(GaudiOnline.MSG_WARNING,'+++ OnlineEnv: %s Level:%d',OnlineEnvBase.__file__,OnlineEnvBase.OutputLevel) application.setup_mbm_access('Events', True) writer = None writer = application.setup_mbm_output('EventOutput') @@ -31,8 +31,8 @@ writer.MBM_maxConsumerWait = 10 writer.RequireODIN = False # application.setup_hive(FlowManager("EventLoop"), 40) -application.setup_algorithms(writer, 1.0) application.setup_monitoring() +application.setup_algorithms(writer, 1.0) application.monSvc.DimUpdateInterval = 1 application.config.numEventThreads = 10 application.config.MBM_numConnections = 2 diff --git a/Online/SmiController/scripts/TestStorageReader.sh b/Online/SmiController/scripts/TestStorageReader.sh index 83c7de473f837289bc4452c1d6996c018e65994d..4c70cc0f28899ca9e2bc27581883b93322b866f3 100755 --- a/Online/SmiController/scripts/TestStorageReader.sh +++ b/Online/SmiController/scripts/TestStorageReader.sh @@ -9,5 +9,5 @@ # # ========================================================================= # -`dataflow_task Class1` `dataflow_default_options ${TASK_TYPE}`; +`dataflow_task Class2` `dataflow_default_options ${TASK_TYPE}`; diff --git a/Online/SmiController/scripts/TestStorageWriter.sh b/Online/SmiController/scripts/TestStorageWriter.sh index 83c7de473f837289bc4452c1d6996c018e65994d..4c70cc0f28899ca9e2bc27581883b93322b866f3 100755 --- a/Online/SmiController/scripts/TestStorageWriter.sh +++ b/Online/SmiController/scripts/TestStorageWriter.sh @@ -9,5 +9,5 @@ # # ========================================================================= # -`dataflow_task Class1` `dataflow_default_options ${TASK_TYPE}`; +`dataflow_task Class2` `dataflow_default_options ${TASK_TYPE}`; diff --git a/Online/FarmConfig/job/EBStorage.sh b/Online/SmiController/scripts/TestStorageWriterNFS.sh similarity index 80% rename from Online/FarmConfig/job/EBStorage.sh rename to Online/SmiController/scripts/TestStorageWriterNFS.sh index d2d5bdc8162302967959cd072910c5d9e7548215..391e499e74015d82006a9654b93a0de7e71918eb 100755 --- a/Online/FarmConfig/job/EBStorage.sh +++ b/Online/SmiController/scripts/TestStorageWriterNFS.sh @@ -9,4 +9,4 @@ # # ========================================================================= # -`dataflow_task Class1` -opts=../options/${TASK_TYPE}.opts; +`dataflow_task Class2` `dataflow_default_options ${TASK_TYPE}`; diff --git a/Online/SmiController/scripts/runTask.sh b/Online/SmiController/scripts/runTask.sh index 6a8629f02a973983e98781f2be7b975952003d28..ccc31287fafdbdfdf3f3b510ece4e532f3d30dc3 100755 --- a/Online/SmiController/scripts/runTask.sh +++ b/Online/SmiController/scripts/runTask.sh @@ -49,7 +49,7 @@ dataflow_default_options() dataflow_task() { echo "exec -a ${UTGID} genRunner.exe libDataflow.so dataflow_run_task -msg=fifo -mon=Dataflow_DIMMonitoring -class=$1"; } # -echo "ERROR: INFO_OPTIONS ${INFO_OPTIONS}"; +## echo "ERROR: INFO_OPTIONS ${INFO_OPTIONS}"; if test "${TASK_TYPE}" = "Controller"; then #echo "${FARMCONFIGROOT}/job/Controller.sh"; . ${FARMCONFIGROOT}/job/Controller.sh; diff --git a/Online/SmiController/src/smi_controller.cpp b/Online/SmiController/src/smi_controller.cpp index b92f49d8cd5a823aa6adcb4ddf9fe27d7f129ff1..f8443be5313e872b10f11260833964bb1294cb17 100644 --- a/Online/SmiController/src/smi_controller.cpp +++ b/Online/SmiController/src/smi_controller.cpp @@ -45,12 +45,12 @@ static void help_ctrl() { " -runinfo=[string] Path to file with python formatted. \n" " information from RunInfo datapoint. \n" " -taskconfig=[string] Path to xml file with slave information. \n" - " -service=[name] DIM service name to steer number of threads. \n" + " -service=[name] DIM service name to steer number lof threads. \n" " -count=[number] Number of Moore processes to be forked. \n" " -replacements=[string] String with replacement items to interprete \n" " the architecture. Items are name-value pairs \n" " separated by a smi-colon: \n" - " Name1=<value1>:Name2=<value2>:.... \n" + " Name1:<value1>,Name2:<value2>,.... \n" " -bindcpus=[number] Flag to bind main processors to CPU slots. \n" " \n" " -smidomain=<name> SMI domain name to join. \n" diff --git a/Online/Storage/Storage/fdb_dbase.h b/Online/Storage/Storage/fdb_dbase.h index c6030864cc2b9fe90efd7ddebd18802861a85b19..f490e47caa73b747f0996d18551b914854bca84b 100644 --- a/Online/Storage/Storage/fdb_dbase.h +++ b/Online/Storage/Storage/fdb_dbase.h @@ -159,27 +159,31 @@ namespace Online { /// Check the existence of a given object in the database virtual std::error_code query_object( const std::string& object_name, - std::string& access_name, - std::string& date, - std::size_t& length); + std::string& access_name, + std::string& date, + std::size_t& length, + bool direct); /// Get the next object with the name matching the prefix virtual std::error_code delete_next( const std::string& prefix, std::string& access_name, std::string& date, - std::size_t& length); + std::size_t& length, + bool direct); /// Check the existence of a given object in the database virtual std::error_code delete_object(const std::string& object_name, std::string& access_name, std::string& date, - std::size_t& length); + std::size_t& length, + bool direct); /// Add a new object to the database virtual std::error_code add_object( const std::string& object_name, const std::string& date, std::size_t length, - std::string& access_name); + std::string& access_name, + bool direct); /// Update the object state of an object in the database virtual std::error_code update_object_state(const std::string& object_name, diff --git a/Online/Storage/src/server/fdb_db_server.cpp b/Online/Storage/src/server/fdb_db_server.cpp index 8d03c8f6d65162e2b181968723e9f764e3c5c8fa..6adc67e496921c44e0d59ed5171a7bb43d543cb5 100644 --- a/Online/Storage/src/server/fdb_db_server.cpp +++ b/Online/Storage/src/server/fdb_db_server.cpp @@ -101,10 +101,11 @@ template <> http::HttpRequestHandler::continue_action http::basic_http_server<db>::handler_t::handle_get(const request_t& req, reply_t& rep) { size_t length = 0; string date, access_name, obj = object_name(req.uri); + auto* hdr_location = req.header(http::constants::location); error_code ec; { dbase_t::lock_t lock(dbase.get()); - ec = dbase->query_object(req.uri, access_name, date, length); + ec = dbase->query_object(req.uri, access_name, date, length, hdr_location != nullptr); } if ( ec == std::errc::no_such_file_or_directory ) { rep = reply_t::stock_reply(reply_t::not_found); @@ -144,10 +145,11 @@ template <> http::HttpRequestHandler::continue_action http::basic_http_server<db>::handler_t::handle_delete(const request_t& req, reply_t& rep) { size_t length = 0; string date, access_name, obj = object_name(req.uri,"%"); + auto* hdr_location = req.header(http::constants::location); std::error_code ec; { dbase_t::lock_t lock(dbase.get()); - ec = dbase->delete_object(obj, access_name, date, length); + ec = dbase->delete_object(obj, access_name, date, length, hdr_location != nullptr); } if ( ec == std::errc::no_such_file_or_directory ) { rep = reply_t::stock_reply(reply_t::not_found); @@ -209,11 +211,7 @@ http::basic_http_server<db>::handler_t::handle_put(const request_t& req, reply_t string access_name; std::error_code ec; { dbase_t::lock_t lock(dbase.get()); - ec = dbase->add_object(req.uri, date, len, access_name); - if ( hdr_location && error_code_ok(ec, this->debug) ) { - access_name = hdr_location->value; - dbase->update_object_state(req.uri, "WRITTEN"); - } + ec = dbase->add_object(req.uri, date, len, access_name, hdr_location != nullptr); } if ( ec == std::errc::permission_denied ) { header_t h(http::constants::error_cause,"Failed to add "+req.uri+" "+ec.message()); diff --git a/Online/Storage/src/server/fdb_dbase.cpp b/Online/Storage/src/server/fdb_dbase.cpp index 11aefcd0b1af14c3dde41efebcfaaef3b54ecb0f..45c34968f29def0fd988cfe7d1593d37e6342dc3 100644 --- a/Online/Storage/src/server/fdb_dbase.cpp +++ b/Online/Storage/src/server/fdb_dbase.cpp @@ -46,7 +46,7 @@ fdb_dbase_t::handler_t::query(std::string& object, if ( ec.value() == 0 ) { object = file.name; host = file.host; - length = file.size; // ::atol(file.size.c_str()); + length = file.size; date = file.date; ::lib_rtl_output(_prt(this), "+++ Query '%s'", object.c_str()); return ec; @@ -66,7 +66,7 @@ fdb_dbase_t::handler_t::next( std::string& object, if ( ec.value() == 0 ) { object = file.name; host = file.host; - length = file.size; // ::atol(file.size.c_str()); + length = file.size; date = file.date; ec = this->set(object, handler_t::STATE_READ); if ( ec.value() == 0 ) { @@ -109,12 +109,13 @@ std::string fdb_dbase_t::network_file(const std::string& host, const std::string std::error_code fdb_dbase_t::query_object(const std::string& object, std::string& access, std::string& date, - std::size_t& length) + std::size_t& length, + bool direct) { - std::string host, obj = this->object_key(object); + std::string host, obj = direct ? object : this->object_key(object); auto ec = this->_engine->query(obj, host, date, length); if ( ec.value() == 0 ) { - access = this->network_file(host, obj); + access = direct ? obj : this->network_file(host, obj); ::lib_rtl_output(_prt(this), "+++ Lookup '%s'", obj.c_str()); return ec; } @@ -127,13 +128,14 @@ std::error_code fdb_dbase_t::query_object(const std::string& object, std::error_code fdb_dbase_t::delete_next( const std::string& object, std::string& access, std::string& date, - std::size_t& length) + std::size_t& length, + bool direct) { - std::string host, obj = this->object_key(object); + std::string host, obj = direct ? object : this->object_key(object); auto ec = this->_engine->next(obj, host, date, length); if ( ec.value() == 0 ) { - ec = this->_engine->del(obj); - access = this->network_file(host, obj); + ec = this->_engine->del(obj); + access = direct ? obj : this->network_file(host, obj); if ( ec.value() == 0 ) { ::lib_rtl_output(_prt(this), "+++ Lookup '%s'", obj.c_str()); return ec; @@ -148,13 +150,14 @@ std::error_code fdb_dbase_t::delete_next( const std::string& object, std::error_code fdb_dbase_t::delete_object(const std::string& object, std::string& access, std::string& date, - std::size_t& length) + std::size_t& length, + bool direct) { - std::string host, obj = this->object_key(object); + std::string host, obj = direct ? object : this->object_key(object); auto ec = this->_engine->query(obj, host, date, length); if ( !ec ) { - ec = this->_engine->del(obj); - access = this->network_file(host, obj); + ec = this->_engine->del(obj); + access = direct ? obj : this->network_file(host, obj); if ( !ec ) { ::lib_rtl_output(_prt(this), "+++ Remove '%s'", obj.c_str()); return ec; @@ -170,17 +173,18 @@ std::error_code fdb_dbase_t::add_object(const std::string& object, const std::string& date, std::size_t length, - std::string& access) + std::string& access, + bool direct) { - std::string obj = this->object_key(object); - std::string host = this->get_free_host_uri(object); + std::string obj = direct ? object : this->object_key(object); + std::string host = direct ? std::string() : this->get_free_host_uri(object); auto ec = this->_engine->add(obj, date, length, host); if ( !ec ) { - access = this->network_file(host, obj); + access = direct ? obj : this->network_file(host, obj); ::lib_rtl_output(_prt(this), "+++ Add '%s' %s %s", object.c_str(), this->_debug > 1 ? "access:" : "", this->_debug > 1 ? access.c_str() : ""); - return ec; + return direct ? this->_engine->set(obj, handler_t::STATE_WRITTEN) : ec; } ::lib_rtl_output(LIB_RTL_ERROR,"+++ FAILED add: '%s' access: %s [%s]", object.c_str(), access.c_str(), ec.message().c_str()); diff --git a/Online/Tell1Data/Tell1Data/EventHeader.h b/Online/Tell1Data/Tell1Data/EventHeader.h index 48b3fcbfaef005b89a20dc58f1c3bd9d41d83374..6748843007352ad523edf6fc295b8bfc66e96ae7 100644 --- a/Online/Tell1Data/Tell1Data/EventHeader.h +++ b/Online/Tell1Data/Tell1Data/EventHeader.h @@ -265,9 +265,23 @@ namespace Online { /// Set spare word void setSpare(unsigned char val) { m_spare[0] = val; } /// Access to data payload (Header MUST be initialized) - unsigned char* data() { return ((unsigned char*)this)+sizeOf(headerVersion()); } + template <typename T=unsigned char> + T* data() { return (T*)((unsigned char*)this)+sizeOf(headerVersion()); } /// Access to data payload (Header MUST be initialized) - const unsigned char* data() const { return ((unsigned char*)this)+sizeOf(headerVersion()); } + template <typename T=unsigned char> + const T* data() const { return (T*)((unsigned char*)this)+sizeOf(headerVersion()); } + /// Access to data payload (Header MUST be initialized) + template <typename T=unsigned char> + T* end() { return (T*)((unsigned char*)this)+size0(); } + /// Access to data payload (Header MUST be initialized) + template <typename T=unsigned char> + const T* end() const { return (T*)((unsigned char*)this)+size0(); } + + template <typename T> struct Interval { T *start, *end; }; + template <typename T=unsigned char> + Interval<T> data_frame() { return {this->data<T>(), this->end<T>()}; } + template <typename T=unsigned char> + Interval<const T> data_frame() const { return {this->data<T>(), this->end<T>()}; } /// Access to sub-headers SubHeader subHeader0() { return SubHeader(m_spare-1); } diff --git a/Online/sqldb/sqldb/sqldb.h b/Online/sqldb/sqldb/sqldb.h index 658a807f43706d120b56c32069e4beda21ebc414..6b5dda15a1a31e8587081172418d9f427965dc20 100644 --- a/Online/sqldb/sqldb/sqldb.h +++ b/Online/sqldb/sqldb/sqldb.h @@ -636,21 +636,27 @@ namespace sqldb { /// Access the number of result fields of the prepared statement inline std::size_t statement::param_count() const { + if ( !this->intern.get() ) + throw std::runtime_error("SQLDB: Invalid statement handle!"); return intern->params.size(); } /// Check handle validity inline bool statement::is_valid() const { - return intern->stmt != nullptr; + return intern.get() != nullptr && intern->stmt != nullptr; } /// Access error message on failure inline std::string statement::errmsg() const { + if ( !this->intern.get() ) + throw std::runtime_error("SQLDB: Invalid statement handle!"); return intern->errmsg(); } /// Character string of the prepared statement inline const char* statement::sql() const { + if ( !this->intern.get() ) + throw std::runtime_error("SQLDB: Invalid statement handle!"); return intern->sql(); } @@ -661,6 +667,8 @@ namespace sqldb { /// Access raw parameter data from statement handle inline column_data& statement::param(std::size_t column) const { + if ( !this->intern.get() ) + throw std::runtime_error("SQLDB: Invalid statement handle!"); if ( column >= intern->params.size() ) invalid_statement("Invalid column identifier"); return intern->params.at(column); @@ -668,6 +676,8 @@ namespace sqldb { /// Access raw data from result handle inline column_data& statement::_field(std::size_t column) const { + if ( !this->intern.get() ) + throw std::runtime_error("SQLDB: Invalid statement handle!"); if ( column >= intern->fields.size() ) invalid_statement("Invalid column identifier"); return intern->fields.at(column); @@ -675,21 +685,25 @@ namespace sqldb { /// Access the number of rows affected by the last statement inline long statement::rows_affected() const { - return intern->rows_affected(); + if ( this->intern.get() ) return this->intern->rows_affected(); + throw std::runtime_error("SQLDB: Invalid statement handle!"); } /// Access the number of result fields of the prepared statement inline std::size_t record::field_count() const { - return this->stmt->intern->fields.size(); + if ( this->stmt && this->stmt->intern.get() ) return this->stmt->intern->fields.size(); + throw std::runtime_error("SQLDB: Invalid statement handle!"); } /// Access raw data from result handle inline column_data& record::field(std::size_t column) const { - return this->stmt->_field(column); + if ( this->stmt ) return this->stmt->_field(column); + throw std::runtime_error("SQLDB: Invalid statement handle!"); } inline bool record::is_null(std::size_t col) const { - return this->stmt->_field(col).null; + if ( this->stmt ) return this->stmt->_field(col).null; + throw std::runtime_error("SQLDB: Invalid statement handle!"); } } // End namespace sqldb diff --git a/TestBeam/job/EventTest.py b/TestBeam/job/EventTest.py index e23340c83a239208aaa2c5d0611e5ff54a7194d8..a1b7df2dbe4b7fe26fbe6c8e9de0fb5a547d2679 100644 --- a/TestBeam/job/EventTest.py +++ b/TestBeam/job/EventTest.py @@ -22,9 +22,9 @@ application = GaudiOnline.Passthrough(outputLevel=OnlineEnv.OutputLevel, application.setup_fifolog() application.setup_mbm_access('Monitor', True) application.setup_hive(FlowManager("EventLoop"), 40) +application.setup_monitoring() wr = application.setup_algorithms(None, 1.0) wr.RequireODIN = False -application.setup_monitoring() application.monSvc.DimUpdateInterval = 1 # Mode slection:: synch: 0 async_queued: 1 sync_queued: 2 application.config.execMode = 0 diff --git a/TestBeam/job/Monitor.py b/TestBeam/job/Monitor.py index 65a90ab94724bbc18426b4d0bf53a0aa54088888..5f91bf6a6033febba9ec8ff7547f8521bf07b414 100644 --- a/TestBeam/job/Monitor.py +++ b/TestBeam/job/Monitor.py @@ -30,10 +30,11 @@ writer.MaxEventsPerTransaction = 10 writer.UseRawData = False writer.RequireODIN = False +ev_size = Configurables.Online__EventSize('EventSize') application.setup_hive(FlowManager("EventLoop"), 40) application.setup_monitoring() #application.setup_algorithms(writer, 0.05) -application.setup_algorithms(writer, 1.0) +application.setup_algorithms([ev_size,writer], 1.0) application.monSvc.DimUpdateInterval = 1 application.config.burstPrintCount = 30000 diff --git a/TestBeam/job/RcvMonitor.py b/TestBeam/job/RcvMonitor.py index d350d4587f565becb5d47a475157a3fb9baef334..5e94bdd67b83a61adf0ec36f5e96a3c1beaaec98 100644 --- a/TestBeam/job/RcvMonitor.py +++ b/TestBeam/job/RcvMonitor.py @@ -27,7 +27,8 @@ application.setup_monitoring() algo = None algo = Configurables.StoreExplorerAlg('Explorer') algo.PrintFreq = 0.0000005 -wr = application.setup_algorithms(writer=algo, acceptRate=1.0) +ev_size = Configurables.Online__EventSize('EventSize') +wr = application.setup_algorithms(writer=[algo,ev_size], acceptRate=1.0) wr.RequireODIN = False application.input.MakeRawEvent = True application.config.burstPrintCount = 20000 diff --git a/TestBeam/job/runTask.sh b/TestBeam/job/runTask.sh index 33d8dc510ae8605ac7bd044327c383d86816e59c..92239e3ddfc669aeb7ee2ae7e7472deda5a5b330 100755 --- a/TestBeam/job/runTask.sh +++ b/TestBeam/job/runTask.sh @@ -9,26 +9,11 @@ # # ========================================================================= # -if test -z "${DIM_DNS_NODE}"; then - if [ -r /etc/sysconfig/dim ]; then - . /etc/sysconfig/dim; - fi; -fi; -# -# -export UTGID=${UTGID} -if test -n "${LOGFIFO}"; then - export LOGFIFO=${LOGFIFO}; -fi; -# -export DIM_DNS_NODE; -# # Switch to the task directory and execute the controller process # --------------------------------------------------------------- export CMTCONFIG=x86_64_v2-centos7-gcc10-opt; export CMTCONFIG=x86_64_v2-centos7-gcc10-do0; # -# if test -z "${SCRIPT}"; then SCRIPT=`realpath $0`; fi; @@ -36,7 +21,6 @@ SCRIPT_DIR=`dirname ${SCRIPT}`; TESTBEAM_DIR=`dirname ${SCRIPT_DIR}`; DIR=`dirname ${TESTBEAM_DIR}`; # -# . ${DIR}/setup.${CMTCONFIG}.vars; . ${FARMCONFIGROOT}/job/createEnvironment.sh $*; # @@ -94,8 +78,10 @@ elif test -f "${OPTIONS}" -a -n "`echo ${OPTIONS} | grep .opts`"; then `dataflow_task ${CLASS}` -opts=${OPTIONS} ${AUTO_STARTUP} ${DEBUG_STARTUP}; fi; elif test -f ./../../Online/FarmConfig/job/${TASK_TYPE}.sh; then - echo "[ERROR] ./../../Online/FarmConfig/job/${TASK_TYPE}.sh $*"; - . ./../../Online/FarmConfig/job/${TASK_TYPE}.sh $*; + #echo "[ERROR] ./../../Online/FarmConfig/job/${TASK_TYPE}.sh $*"; + cd `realpath ./../../Online/FarmConfig/job`; + echo "$UTGID : `pwd`"; + . ./${TASK_TYPE}.sh $*; else echo "+++ Running generic default task as '${TASK_TYPE}'"; exec -a ${UTGID} genPython.exe ${SMICONTROLLERROOT}/scripts/DummyTask.py -utgid ${UTGID} -partition 103 -print ${OUTPUT_LEVEL};