def testTableName(self): ''' Test table name generation ''' # This is to circumvent the need to start up TEAL to set the variable db_interface.TABLE_TEMPLATE = 'x_{0}' # Tests fmt_raw_data = 0x5445535400001234 fmt_db_data1 = 0x5445535480001234 fmt_db_data2 = 0x5445535480F812AB self.assertFalse(extdata_fmt2table_name(fmt_raw_data)) self.assertEqual(extdata_fmt2table_name(fmt_db_data1),'x_TEST_0_1234') self.assertEqual(extdata_fmt2table_name(fmt_db_data2),'x_TEST_F8_12AB')
signal.signal(signal.SIGTERM, app_terminate) # Process Termination if options.log_file is None: log_file = '$TEAL_LOG_DIR/tlufm.log' else: log_file = options.log_file try: # Set up the TEAL environment to get at the data required for logging t = teal.Teal(None, data_only=True, msgLevel=options.msg_level, logFile=log_file, daemon_mode=options.run_as_daemon) IB_TEAL_EXTDATA_TABLE = extdata.extdata_fmt2table_name(IB_TEAL_EXTDATA_V1_T1) # Map thread id to name thread_dict = {} logger = registry.get_logger() # Start Infiniband connector ib = InfiniBand() ib.start() # Wait for Teal to shutdown before exiting shutdown = registry.get_service(registry.SERVICE_SHUTDOWN) shutdown.wait() except SystemExit, se: raise except: registry.get_logger().exception("UFM connector failed") sys.exit(1)
def generate_event_log(self, event_lines): ''' Generate the event data required to log an AMM event This will return two tuples, the first one is the data for the common event structure and the second is for the extended data ''' t = Teal(None, data_only=True, msgLevel='warn', logFile='$TEAL_LOG_DIR/tlammtraphandler.log') db = registry.get_service(registry.SERVICE_DB_INTERFACE) event_valid = self.is_valid() # Generate the event id src_comp = 'AMM' if event_valid: event_id = hex(self.evt_name).upper()[2:].rjust(8,'0') # Check if this event should be reported or not if event_filtered(event_id): return time_occurred = self.date_time src_loc_type = 'D' try: src_node_address = socket.gethostbyaddr(self.sys_ip_address)[0] except socket.herror: src_node_address = self.sys_ip_address if (self.source_id.startswith('BLADE_')): tmp_loc = find_blade_name(db, self.sys_ip_address, self.source_id) # If a node was found, use that instead of the AMM address if (tmp_loc != self.source_id): src_loc = tmp_loc else: # Unknown blade - report it as a subcomponent of the AMM src_loc = '{0}##{1}'.format(src_node_address, self.source_id) else: src_loc = '{0}##{1}'.format(src_node_address, self.source_id) rpt_comp = 'AMM' rpt_loc_type = 'A' rpt_loc = src_node_address else: event_id = AMM_INVALID_EVENT time_occurred = datetime.now() src_loc_type = 'A' src_loc = socket.gethostname() rpt_comp = None rpt_loc_type = None rpt_loc = None # Generate the extended data if event_valid: raw_data_fmt = AMM_EXTDATA_FMT raw_data = None exd = (self.app_id, self.sp_txt_id, self.sys_uuid, self.sys_sern, self.app_type, self.priority, self.msg_text, self.host_contact, self.host_location, self.blade_name, self.blade_sern, self.blade_uuid, self.evt_name, self.source_id, self.call_home_flag, self.sys_ip_address, self.sys_machine_model, self.blade_machine_model) else: raw_data_fmt = 0 raw_data = event_lines[0:2048] exd = None # Generate the common base event conn = db.get_connection() cursor = conn.cursor() cbe = (event_id, time_occurred, src_comp, src_loc_type, src_loc, rpt_comp, rpt_loc_type, rpt_loc, raw_data_fmt, raw_data) db.insert(cursor, [event.EVENT_ATTR_EVENT_ID, event.EVENT_ATTR_TIME_OCCURRED, event.EVENT_ATTR_SRC_COMP, event.EVENT_ATTR_SRC_LOC_TYPE, event.EVENT_ATTR_SRC_LOC, event.EVENT_ATTR_RPT_COMP, event.EVENT_ATTR_RPT_LOC_TYPE, event.EVENT_ATTR_RPT_LOC, event.EVENT_ATTR_RAW_DATA_FMT, event.EVENT_ATTR_RAW_DATA], db_interface.TABLE_EVENT_LOG, parms=cbe) if exd: db.insert_dependent(cursor, event.EVENT_ATTR_REC_ID, [AMM_APP_ID, AMM_SP_TXT_ID, AMM_SYS_UUID, AMM_SYS_SERN, AMM_APP_TYPE, AMM_PRIORITY, AMM_MSG_TEXT, AMM_HOST_CONTACT, AMM_HOST_LOCATION, AMM_BLADE_NAME, AMM_BLADE_SERN, AMM_BLADE_UUID, AMM_EVT_NAME, AMM_SOURCE_ID, AMM_CALL_HOME_FLAG, AMM_SYS_IP_ADDRESS, AMM_SYS_MACHINE_MODEL, AMM_BLADE_MACHINE_MODEL], extdata.extdata_fmt2table_name(AMM_EXTDATA_FMT), parms=exd) conn.commit() cursor.close() conn.close() t.shutdown() # Tell TEAL that a new event has been added teal_semaphore.Semaphore().post()