Add redfish support detection to maintenance

This update

1. Refactors some of the common maintenance ipmi
   definitions and utilities into a more generic
   'bmcUtil' module to reduce code duplication and improve
   improve code reuse with the introduction of a second
   bmc communication protocol ; redfish.

2. Creates a new 'redFishUtil' module similar to the existing
   'ipmiUtil' module but in support of common redfish
   utilities and definitions that can be used by both
   maintenance and the hardware monitor.

3. Moves the existing 'mtcIpmiUtil' module to a more common
   'mtcBmcUtil' and renames the 'ipmi_command_send/recv' to
   the more generic 'bmc_command_send/recv' which are enhanced
   to support both ipmi and redfish bmc communication methods.

4. Renames the bmc info collection and connection monitor ;
   'bm_handler' to 'bmc_handler' and adds support necessary
   to learn if a host's bmc supports redfish.

5. Renames the existing 'mtcThread_ipmitool' to a more common
   'mtcThread_bmc' and redfishtool support for the now common
   set of bmc thread commands and the addition of the new
   redfishtool bmc query, aka 'redfish root query', used to
   detect if a host's bmc supports redfish.

   Note: This aspect is the primary feature of this update.

         Namely the ability to detect and print a log indicating
         if a host's bmc supports redfish.

Test Plan:

PASS: Verify sensor monitoring and alarming still works.
PASS: Verify power-off command handling.
PASS: Verify power-on command handling.
PASS: Verify reset command handling.
PASS: Verify reinstall (netboot) command handling.
PASS: Verify logging when redfish is not supported.
PASS: Verify logging when redfish is supported.
PASS: Verify ipmitool is used regardless of redfish support.
PASS: Verify mtce thread error handling for both protocols.

Change-Id: I72e63958f61d10f5c0d4a93a49a7f39bdd53a76f
Story: 2005861
Task: 35825
Signed-off-by: Eric MacDonald <eric.macdonald@windriver.com>
changes/40/671340/10
Eric MacDonald 3 years ago
parent 5b9ae3a5ff
commit 804ec52227
  1. 6
      devstack/lib/metal
  2. 4
      mtce-common/centos/mtce-common.spec
  3. 4
      mtce-common/src/common/Makefile
  4. 260
      mtce-common/src/common/bmcUtil.cpp
  5. 92
      mtce-common/src/common/bmcUtil.h
  6. 9
      mtce-common/src/common/fitCodes.h
  7. 34
      mtce-common/src/common/hostUtil.h
  8. 71
      mtce-common/src/common/ipmiUtil.cpp
  9. 74
      mtce-common/src/common/ipmiUtil.h
  10. 20
      mtce-common/src/common/nodeBase.h
  11. 1
      mtce-common/src/common/nodeTimers.h
  12. 184
      mtce-common/src/common/redfishUtil.cpp
  13. 53
      mtce-common/src/common/redfishUtil.h
  14. 26
      mtce-common/src/common/threadUtil.h
  15. 3
      mtce/centos/mtce.spec
  16. 159
      mtce/src/common/nodeClass.cpp
  17. 61
      mtce/src/common/nodeClass.h
  18. 19
      mtce/src/heartbeat/hbsStubs.cpp
  19. 2
      mtce/src/hwmon/Makefile
  20. 2
      mtce/src/hwmon/hwmon.h
  21. 22
      mtce/src/hwmon/hwmonClass.cpp
  22. 8
      mtce/src/hwmon/hwmonClass.h
  23. 18
      mtce/src/hwmon/hwmonFsm.cpp
  24. 274
      mtce/src/hwmon/hwmonHdlr.cpp
  25. 26
      mtce/src/hwmon/hwmonIpmi.cpp
  26. 2
      mtce/src/hwmon/hwmonSensor.cpp
  27. 22
      mtce/src/hwmon/hwmonThreads.cpp
  28. 8
      mtce/src/hwmon/hwmonUtil.cpp
  29. 6
      mtce/src/maintenance/Makefile
  30. 297
      mtce/src/maintenance/ipmiClient.h
  31. 372
      mtce/src/maintenance/mtcBmcUtil.cpp
  32. 16
      mtce/src/maintenance/mtcBmcUtil.h
  33. 0
      mtce/src/maintenance/mtcBrdMgmt.cpp
  34. 0
      mtce/src/maintenance/mtcBrdMgmt.h
  35. 22
      mtce/src/maintenance/mtcCmdHdlr.cpp
  36. 348
      mtce/src/maintenance/mtcIpmiUtil.cpp
  37. 89
      mtce/src/maintenance/mtcIpmiUtil.h
  38. 20
      mtce/src/maintenance/mtcNodeCtrl.cpp
  39. 4
      mtce/src/maintenance/mtcNodeFsm.cpp
  40. 775
      mtce/src/maintenance/mtcNodeHdlrs.cpp
  41. 510
      mtce/src/maintenance/mtcThreads.cpp
  42. 4
      mtce/src/maintenance/mtcThreads.h

@ -163,7 +163,7 @@ function install_mtce_common {
local libdaecom_file=( \
"common/libcommon.a" \
"common/libthreadUtil.a" \
"common/libipmiUtil.a" \
"common/libbmcUtils.a" \
"common/libpingUtil.a" \
"common/libnodeBase.a" \
"common/libregexUtil.a" \
@ -190,7 +190,9 @@ function install_mtce_common {
"common/timeUtil.h" \
"common/alarmUtil.h" \
"common/hostUtil.h" \
"common/bmcUtil.h" \
"common/ipmiUtil.h" \
"common/redfishUtil.h" \
"common/nlEvent.h" \
"common/pingUtil.h" \
"common/regexUtil.h" \
@ -898,7 +900,7 @@ function cleanup_metal {
local libdaecom_file=( \
"libcommon.a" \
"libthreadUtil.a" \
"libipmiUtil.a" \
"libBmcUtils.a" \
"libpingUtil.a" \
"libnodeBase.a" \
"libregexUtil.a" \

@ -99,7 +99,7 @@ install -m 755 -d %{buildroot}%{_libdir}
install -m 644 -p -D %{_buildsubdir}/daemon/libdaemon.a %{buildroot}%{_libdir}
install -m 644 -p -D %{_buildsubdir}/common/libcommon.a %{buildroot}%{_libdir}
install -m 644 -p -D %{_buildsubdir}/common/libthreadUtil.a %{buildroot}%{_libdir}
install -m 644 -p -D %{_buildsubdir}/common/libipmiUtil.a %{buildroot}%{_libdir}
install -m 644 -p -D %{_buildsubdir}/common/libbmcUtils.a %{buildroot}%{_libdir}
install -m 644 -p -D %{_buildsubdir}/common/libpingUtil.a %{buildroot}%{_libdir}
install -m 644 -p -D %{_buildsubdir}/common/libnodeBase.a %{buildroot}%{_libdir}
install -m 644 -p -D %{_buildsubdir}/common/libregexUtil.a %{buildroot}%{_libdir}
@ -134,6 +134,8 @@ install -m 644 -p -D %{_buildsubdir}/daemon/daemon_option.h %{buildroot}%{_inclu
install -m 644 -p -D %{_buildsubdir}/common/alarmUtil.h %{buildroot}%{_includedir}/mtce-common
install -m 644 -p -D %{_buildsubdir}/common/hostUtil.h %{buildroot}%{_includedir}/mtce-common
install -m 644 -p -D %{_buildsubdir}/common/ipmiUtil.h %{buildroot}%{_includedir}/mtce-common
install -m 644 -p -D %{_buildsubdir}/common/redfishUtil.h %{buildroot}%{_includedir}/mtce-common
install -m 644 -p -D %{_buildsubdir}/common/bmcUtil.h %{buildroot}%{_includedir}/mtce-common
install -m 644 -p -D %{_buildsubdir}/common/nlEvent.h %{buildroot}%{_includedir}/mtce-common
install -m 644 -p -D %{_buildsubdir}/common/pingUtil.h %{buildroot}%{_includedir}/mtce-common
install -m 644 -p -D %{_buildsubdir}/common/regexUtil.h %{buildroot}%{_includedir}/mtce-common

@ -8,7 +8,9 @@ SHELL = /bin/bash
SRCS = regexUtil.cpp \
timeUtil.cpp \
bmcUtil.cpp \
ipmiUtil.cpp \
redfishUtil.cpp \
pingUtil.cpp \
keyClass.cpp \
hostClass.cpp \
@ -76,7 +78,7 @@ threadUtil:
library:
ar rcs libcommon.a $(COMMON_OBJS) $(EXTRAARFLAGS)
ar rcs libipmiUtil.a ipmiUtil.o $(EXTRAARFLAGS)
ar rcs libbmcUtils.a bmcUtil.o ipmiUtil.o redfishUtil.o $(EXTRAARFLAGS)
ar rcs libpingUtil.a pingUtil.o $(EXTRAARFLAGS)
ar rcs libnodeBase.a nodeBase.o $(EXTRAARFLAGS)
ar rcs libregexUtil.a regexUtil.o $(EXTRAARFLAGS)

@ -0,0 +1,260 @@
/*
* Copyright (c) 2019 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*
*
*
* @file
* Starling-X Common Bmc Utilities
*/
#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;
#include "nodeBase.h" /* for ... mtce-common node definitions */
#include "hostUtil.h" /* for ... mtce-common host definitions */
#include "bmcUtil.h" /* for ... mtce-common bmc utility header */
/**********************************************************************
*
* Name : bmcUtil_getCmd_str
*
* Purpose : logging ; bmc request
*
* Description: return string representing command
*
* Construct : static array of bmc request strings
*
* bmcUtil_request_str_array
*
* Assumptions: initialized in module init
*
**********************************************************************/
static std::string bmcUtil_request_str_array [BMC_THREAD_CMD__LAST+1] ;
string bmcUtil_getCmd_str ( int command )
{
if ( command >= BMC_THREAD_CMD__LAST )
{
slog ("Invalid thread command (%d)\n", command );
return (bmcUtil_request_str_array[BMC_THREAD_CMD__LAST]);
}
return (bmcUtil_request_str_array[command]);
}
/**********************************************************************
*
* Name : bmcUtil_getAction_str
*
* Purpose : logging ; bmc action
*
* Description: return string representing action
*
* Construct : static array of bmc action strings
*
* bmcUtil_action_str_array
*
* Assumptions: initialized in module init
*
**********************************************************************/
static std::string bmcUtil_action_str_array [BMC_THREAD_CMD__LAST+1] ;
string bmcUtil_getAction_str ( int action )
{
if ( action >= BMC_THREAD_CMD__LAST )
{
slog ("Invalid thread action (%d)\n", action );
return (bmcUtil_action_str_array[BMC_THREAD_CMD__LAST]);
}
return (bmcUtil_action_str_array[action]);
}
/**********************************************************************
*
* Name : bmcUtil_getProtocol_str
*
* Purpose : logging ; bmc protocol name
*
* Description: return string representing bmc protocol name
*
**********************************************************************/
string bmcUtil_getProtocol_str ( bmc_protocol_enum protocol )
{
switch (protocol)
{
case BMC_PROTOCOL__REDFISHTOOL: return("redfishtool");
case BMC_PROTOCOL__IPMITOOL: return("ipmitool");
default: return("unknown");
}
}
/*************************************************************************
*
* Name : bmcUtil_init
*
* Purpose : Initialize various common Board Management support
* service functions and aspects.
*
* Description: Init support for IPMI and Redfish
*
* Returns : Initialization result ; always PASS (for now)
*
*************************************************************************/
int bmcUtil_init ( void )
{
daemon_make_dir(BMC_OUTPUT_DIR) ;
ipmiUtil_init ();
redfishUtil_init ();
#ifdef WANT_FIT_TESTING
daemon_make_dir(FIT__INFO_FILEPATH);
#endif
/* init static strings */
bmcUtil_request_str_array[BMC_THREAD_CMD__POWER_RESET] = "Reset";
bmcUtil_request_str_array[BMC_THREAD_CMD__POWER_ON] = "Power-On";
bmcUtil_request_str_array[BMC_THREAD_CMD__POWER_OFF] = "Power-Off";
bmcUtil_request_str_array[BMC_THREAD_CMD__POWER_CYCLE] = "Power-Cycle";
bmcUtil_request_str_array[BMC_THREAD_CMD__BMC_QUERY] = "Query BMC Root";
bmcUtil_request_str_array[BMC_THREAD_CMD__BMC_INFO] = "Query BMC Info";
bmcUtil_request_str_array[BMC_THREAD_CMD__POWER_STATUS] = "Query Power Status";
bmcUtil_request_str_array[BMC_THREAD_CMD__RESTART_CAUSE] = "Query Reset Reason";
bmcUtil_request_str_array[BMC_THREAD_CMD__BOOTDEV_PXE] = "Netboot";
bmcUtil_request_str_array[BMC_THREAD_CMD__READ_SENSORS] = "Read Sensors";
bmcUtil_request_str_array[BMC_THREAD_CMD__LAST] = "unknown";
bmcUtil_action_str_array[BMC_THREAD_CMD__POWER_RESET] = "resetting";
bmcUtil_action_str_array[BMC_THREAD_CMD__POWER_ON] = "powering on";
bmcUtil_action_str_array[BMC_THREAD_CMD__POWER_OFF] = "powering off";
bmcUtil_action_str_array[BMC_THREAD_CMD__POWER_CYCLE] = "power cycling";
bmcUtil_action_str_array[BMC_THREAD_CMD__BMC_QUERY] = "querying bmc root";
bmcUtil_action_str_array[BMC_THREAD_CMD__BMC_INFO] = "querying bmc info";
bmcUtil_action_str_array[BMC_THREAD_CMD__POWER_STATUS] = "querying power status";
bmcUtil_action_str_array[BMC_THREAD_CMD__RESTART_CAUSE] = "querying reset cause";
bmcUtil_action_str_array[BMC_THREAD_CMD__BOOTDEV_PXE] = "setting next boot dev";
bmcUtil_action_str_array[BMC_THREAD_CMD__READ_SENSORS] = "reading sensors";
bmcUtil_action_str_array[BMC_THREAD_CMD__LAST] = "unknown";
return (PASS);
}
/*************************************************************************
*
* Name : bmcUtil_info_init
*
* Purpose : Initialize the BMC information struct.
*
* Returns : nothing
*
*************************************************************************/
void bmcUtil_info_init ( bmc_info_type & bmc_info )
{
bmc_info.device_id.clear();
bmc_info.manufacturer_name.clear();
bmc_info.manufacturer_id.clear();
bmc_info.product_name.clear();
bmc_info.product_id.clear();
bmc_info.fw_version.clear();
bmc_info.hw_version.clear();
}
/*************************************************************************
*
* Name : bmcUtil_create_pw_file
*
* Purpose : Create a randomly named password filename
*
* Description: Create based on protocol.
* Add the password info to the file.
* Attach filename to thread info.
*
* Returns : Error status passed through thread info status
* and status string
*
*************************************************************************/
void bmcUtil_create_pw_file ( thread_info_type * info_ptr,
string pw_file_content,
bmc_protocol_enum protocol )
{
string password_tempfile ;
info_ptr->password_file.clear ();
/* protocol specific output dir */
if ( protocol == BMC_PROTOCOL__REDFISHTOOL )
password_tempfile = REDFISHTOOL_OUTPUT_DIR ;
else
password_tempfile = IPMITOOL_OUTPUT_DIR ;
password_tempfile.append(".") ;
password_tempfile.append(program_invocation_short_name);
password_tempfile.append("-");
password_tempfile.append(info_ptr->hostname);
password_tempfile.append("-");
info_ptr->pw_file_fd = hostUtil_mktmpfile ( info_ptr->hostname,
password_tempfile,
info_ptr->password_file,
pw_file_content );
if ( info_ptr->pw_file_fd <= 0 )
{
info_ptr->status_string = "failed to get an open temporary password filedesc" ;
info_ptr->status = FAIL_FILE_CREATE ;
info_ptr->password_file.clear();
}
else
{
/* clean-up */
if ( info_ptr->pw_file_fd > 0 )
close(info_ptr->pw_file_fd);
info_ptr->pw_file_fd = 0 ;
info_ptr->status_string = "" ;
info_ptr->status = PASS ;
}
}
/*************************************************************************
*
* Name : bmcUtil_create_data_fn
*
* Purpose : Create a outout data filename
*
* Description: Create based on protocol.
*
* Returns : datafile name as a string
*
*************************************************************************/
string bmcUtil_create_data_fn ( string & hostname,
string file_suffix,
bmc_protocol_enum protocol )
{
/* create the output filename */
string datafile ;
/* protocol specific output dir */
if ( protocol == BMC_PROTOCOL__REDFISHTOOL )
datafile = REDFISHTOOL_OUTPUT_DIR ;
else
datafile = IPMITOOL_OUTPUT_DIR ;
datafile.append(program_invocation_short_name);
datafile.append("_");
datafile.append(hostname);
/* add the sensor list command */
datafile.append(file_suffix);
return ( datafile );
}

@ -0,0 +1,92 @@
#ifndef __INCLUDE_BMCUTIL_H__
#define __INCLUDE_BMCUTIL_H__
/*
* Copyright (c) 2017 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*
*/
/**
* @file
* Starling-X BMC Utilities Header
*/
#include "nodeBase.h" /* for ... */
#include "threadUtil.h" /* for ... thread_info_type and utilities */
#define BMC_OUTPUT_DIR ((const char *)("/var/run/bmc/"))
#define BMC_DEFAULT_INFO ((const char *)("{\"power_state\":\"off\",\"protocol\":\"ipmitool\"}"))
/* important BMC query info to log and track */
typedef struct
{
std::string product_name ;
std::string product_id ;
std::string manufacturer_name ;
std::string manufacturer_id ;
std::string device_id ;
std::string fw_version ;
std::string hw_version ;
} bmc_info_type ;
/* BMC commands */
typedef enum
{
BMC_THREAD_CMD__BMC_QUERY = 0,
BMC_THREAD_CMD__POWER_RESET,
BMC_THREAD_CMD__POWER_ON,
BMC_THREAD_CMD__POWER_OFF,
BMC_THREAD_CMD__POWER_CYCLE,
BMC_THREAD_CMD__BMC_INFO,
BMC_THREAD_CMD__POWER_STATUS,
BMC_THREAD_CMD__RESTART_CAUSE,
BMC_THREAD_CMD__BOOTDEV_PXE,
BMC_THREAD_CMD__READ_SENSORS,
BMC_THREAD_CMD__LAST
} bmc_cmd_enum ;
#define BMC_QUERY_FILE_SUFFIX ((const char *)("_root_query"))
#define BMC_INFO_FILE_SUFFIX ((const char *)("_bmc_info"))
#define BMC_POWER_CMD_FILE_SUFFIX ((const char *)("_power_cmd_result"))
#define BMC_BOOTDEV_CMD_FILE_SUFFIX ((const char *)("_bootdev"))
#define BMC_RESTART_CAUSE_FILE_SUFFIX ((const char *)("_restart_cause"))
#define BMC_POWER_STATUS_FILE_SUFFIX ((const char *)("_power_status"))
#define BMC_SENSOR_OUTPUT_FILE_SUFFIX ((const char *)("_sensor_data"))
#define BMC_MAX_RECV_RETRIES (10)
/* get the thread command name string */
string bmcUtil_getCmd_str ( int command );
string bmcUtil_getAction_str ( int action );
string bmcUtil_getProtocol_str ( bmc_protocol_enum protocol );
/* module initialization */
int bmcUtil_init ( void );
/* bmc info initialization */
void bmcUtil_info_init ( bmc_info_type & bmc_info );
/* create the a password file */
void bmcUtil_create_pw_file ( thread_info_type * info_ptr,
string pw_file_content,
bmc_protocol_enum protocol );
/* create the output filename */
string bmcUtil_create_data_fn ( string & hostname,
string file_suffix,
bmc_protocol_enum protocol );
#include "ipmiUtil.h" /* for ... mtce-common ipmi utility header */
#include "redfishUtil.h" /* for ... mtce-common redfish utility header */
#endif

@ -50,10 +50,11 @@
#define MTC_CMD_FIT__AMON_SOCK ("/var/run/fit/amon_sock") /* mtcClient */
#define MTC_CMD_FIT__NO_CLSTR_RSP ("/var/run/fit/no_clstr_rsp") /* hbsClient */
#define MTC_CMD_FIT__NO_MGMNT_RSP ("/var/run/fit/no_mgmnt_rsp") /* hbsClient */
#define MTC_CMD_FIT__LINKLIST ("/var/run/fit/linklist") /* hbsAgent */
#define MTC_CMD_FIT__LINKLIST ("/var/run/fit/linklist") /* hbsAgent */
#define MTC_CMD_FIT__HBSSILENT ("/var/run/fit/hbs_silent_fault") /* hbsAgent */
#define MTC_CMD_FIT__SENSOR_DATA ("/var/run/fit/sensor_data") /* hwmond */
#define MTC_CMD_FIT__SENSOR_DATA ("/var/run/fit/sensor_data") /* hwmond */
#define MTC_CMD_FIT__POWER_CMD ("/var/run/fit/power_cmd_result") /* mtcAgent */
#define MTC_CMD_FIT__ROOT_QUERY ("/var/run/fit/root_query") /* mtcAgent */
#define MTC_CMD_FIT__MC_INFO ("/var/run/fit/mc_info") /* mtcAgent */
#define MTC_CMD_FIT__POWER_STATUS ("/var/run/fit/power_status") /* mtcAgent */
#define MTC_CMD_FIT__RESTART_CAUSE ("/var/run/fit/restart_cause") /* mtcAgent */
@ -117,8 +118,8 @@
#define FIT_CODE__FM_GET_ALARM (41)
#define FIT_CODE__FM_QRY_ALARMS (42)
#define FIT_CODE__IPMI_COMMAND_SEND (60)
#define FIT_CODE__IPMI_COMMAND_RECV (61)
#define FIT_CODE__BMC_COMMAND_SEND (60)
#define FIT_CODE__BMC_COMMAND_RECV (61)
#define FIT_CODE__START_HOST_SERVICES (70)
#define FIT_CODE__STOP_HOST_SERVICES (71)

@ -19,40 +19,6 @@ using namespace std;
#include "nodeBase.h"
/* Supported Server Names */
//#define SERVER__UNKNOWN ((const char*)"Undetermined Server")
//#define SERVER__NOKIA_QUANTA_1234_GEN1 ((const char*)"Quanta Computer")
//#define SERVER__HP_PROLIANT_DL380_GEN9 ((const char*)"ProLiant DL380 Gen9")
//#define SERVER__HP_PROLIANT_DL360_GEN9 ((const char*)"ProLiant DL360 Gen9")
/* Supported Board Management Controller Names */
//#define SERVER_BMC__UNKNOWN ((const char*)"Unknown BMC")
//#define SERVER_BMC__STANDARD_ILO_V3 ((const char*)"iLO 3 Standard")
//#define SERVER_BMC__STANDARD_ILO_V4 ((const char*)"iLO 4 Standard")
/* A list of supported servers */
//typedef enum
//{
// SERVER_IS_UNKNOWN = 0,
// SERVER_IS_NOKIA__QUANTA_1234____GEN1__ILO_V4 = 1,
// SERVER_IS_HP_____PROLIANT_DL380_GEN9__ILO_V4 = 2,
// SERVER_IS_HP_____PROLIANT_DL360_GEN9__ILO_V4 = 3,
// SERVER_IS_LAST = 4
//} server_enum ;
/* Server Table Entry Type */
//typedef struct
//{
// server_enum server_code ;
// protocol_enum protocol ;
// const char * server_name ;
// const char * server_bmc ;
// const char * profile ;
//
//} server_table_entry_type ;
//server_table_entry_type * hostUtil_get_server_info ( server_enum server_code );
typedef enum
{
CLIENT_NONE = 0,

@ -14,9 +14,25 @@
using namespace std;
#include "nodeBase.h" /* for ... mtce node common definitions */
#include "ipmiUtil.h" /* for ... module header */
#include "hostUtil.h" /* for ... mtce host common definitions */
#include "ipmiUtil.h" /* for ... this module header */
/***********************************************************************
*
* Name : ipmiUtil_init
*
* Purpose : Module init
*
* Description: Performs the following functions
*
* 1. creates the ipmitool runtime temp dir
*
***********************************************************************/
int ipmiUtil_init ( void )
{
daemon_make_dir(IPMITOOL_OUTPUT_DIR) ;
return(PASS);
}
/* Create a randomly named password filename */
void ipmiUtil_create_pw_fn ( thread_info_type * info_ptr, string pw )
@ -103,20 +119,8 @@ string ipmiUtil_create_request ( string cmd, string & ip, string & un, string &
return (ipmitool_request);
}
/* init the mc info struct */
void ipmiUtil_mc_info_init ( mc_info_type & mc_info )
{
mc_info.device_id.clear();
mc_info.manufacturer_name.clear();
mc_info.manufacturer_id.clear();
mc_info.product_name.clear();
mc_info.product_id.clear();
mc_info.fw_version.clear();
mc_info.hw_version.clear();
}
/* print a log of the mc info data */
void mc_info_log ( string hostname, mc_info_type & mc_info, int rc )
void ipmiUtil_bmc_info_log ( string hostname, bmc_info_type & bmc_info, int rc )
{
if ( rc )
{
@ -126,16 +130,16 @@ void mc_info_log ( string hostname, mc_info_type & mc_info, int rc )
{
ilog ("%s Manufacturer: %s [id:%s] [ Device: %s ver %s ]\n",
hostname.c_str(),
mc_info.manufacturer_name.c_str(),
mc_info.manufacturer_id.c_str(),
mc_info.device_id.c_str(),
mc_info.hw_version.c_str());
bmc_info.manufacturer_name.c_str(),
bmc_info.manufacturer_id.c_str(),
bmc_info.device_id.c_str(),
bmc_info.hw_version.c_str());
ilog ("%s Product Name: %s [id:%s] [ BMC FW: ver %s ]\n",
hostname.c_str(),
mc_info.product_name.c_str(),
mc_info.product_id.c_str(),
mc_info.fw_version.c_str());
bmc_info.product_name.c_str(),
bmc_info.product_id.c_str(),
bmc_info.fw_version.c_str());
}
}
@ -161,10 +165,10 @@ bool _got_delimited_value ( char * buf_ptr, const char * key, const char * delim
/*****************************************************************************
*
* Name : ipmiUtil_mc_info_load
* Name : ipmiUtil_bmc_info_load
*
* Description: Load the contents of a file containing an ipmitool formatted
* output from an mc info request into the passed in mc_info
* output from an mc info request into the passed in bmc_info
* struct. Loaded info includes
*
* Manufacturer (id/name)
@ -198,10 +202,9 @@ bool _got_delimited_value ( char * buf_ptr, const char * key, const char * delim
**************************************************************************/
#define BUFFER (80)
int ipmiUtil_mc_info_load ( string hostname, const char * filename, mc_info_type & mc_info )
int ipmiUtil_bmc_info_load ( string hostname, const char * filename, bmc_info_type & bmc_info )
{
int rc = FAIL ;
ipmiUtil_mc_info_init ( mc_info );
if ( daemon_is_file_present ( filename ) )
{
FILE * _stream = fopen ( filename, "r" );
@ -211,22 +214,22 @@ int ipmiUtil_mc_info_load ( string hostname, const char * filename, mc_info_type
MEMSET_ZERO(buffer);
while ( fgets (buffer, BUFFER, _stream) )
{
if ( _got_delimited_value ( buffer, MC_INFO_LABEL_FW_VERSION, MC_INFO_LABEL_DELIMITER, mc_info.fw_version ))
if ( _got_delimited_value ( buffer, BMC_INFO_LABEL_FW_VERSION, BMC_INFO_LABEL_DELIMITER, bmc_info.fw_version ))
{
rc = PASS ;
continue;
}
if ( _got_delimited_value ( buffer, MC_INFO_LABEL_HW_VERSION, MC_INFO_LABEL_DELIMITER, mc_info.hw_version ))
if ( _got_delimited_value ( buffer, BMC_INFO_LABEL_HW_VERSION, BMC_INFO_LABEL_DELIMITER, bmc_info.hw_version ))
continue;
if ( _got_delimited_value ( buffer, MC_INFO_LABEL_DEVICE_ID, MC_INFO_LABEL_DELIMITER, mc_info.device_id ))
if ( _got_delimited_value ( buffer, BMC_INFO_LABEL_DEVICE_ID, BMC_INFO_LABEL_DELIMITER, bmc_info.device_id ))
continue;
if ( _got_delimited_value ( buffer, MC_INFO_LABEL_PRODUCT_ID, MC_INFO_LABEL_DELIMITER, mc_info.product_id ))
if ( _got_delimited_value ( buffer, BMC_INFO_LABEL_PRODUCT_ID, BMC_INFO_LABEL_DELIMITER, bmc_info.product_id ))
continue;
if ( _got_delimited_value ( buffer, MC_INFO_LABEL_PRODUCT_NAME, MC_INFO_LABEL_DELIMITER, mc_info.product_name ))
if ( _got_delimited_value ( buffer, BMC_INFO_LABEL_PRODUCT_NAME, BMC_INFO_LABEL_DELIMITER, bmc_info.product_name ))
continue;
if ( _got_delimited_value ( buffer, MC_INFO_LABEL_MANUFACTURE_ID, MC_INFO_LABEL_DELIMITER, mc_info.manufacturer_id ))
if ( _got_delimited_value ( buffer, BMC_INFO_LABEL_MANUFACTURE_ID, BMC_INFO_LABEL_DELIMITER, bmc_info.manufacturer_id ))
continue;
if ( _got_delimited_value ( buffer, MC_INFO_LABEL_MANUFACTURE_NAME, MC_INFO_LABEL_DELIMITER, mc_info.manufacturer_name ))
if ( _got_delimited_value ( buffer, BMC_INFO_LABEL_MANUFACTURE_NAME, BMC_INFO_LABEL_DELIMITER, bmc_info.manufacturer_name ))
continue;
else
blog3 ("buffer: %s\n", buffer );
@ -241,6 +244,6 @@ int ipmiUtil_mc_info_load ( string hostname, const char * filename, mc_info_type
rc = FAIL_FILE_ACCESS ;
}
mc_info_log ( hostname, mc_info, rc );
ipmiUtil_bmc_info_log ( hostname, bmc_info, rc );
return (rc);
}

@ -13,17 +13,20 @@
* Wind River Titanium Cloud's Maintenance Common IPMI Utilities Header
*/
#include "nodeBase.h" /* for ... */
#include "threadUtil.h" /* for ... thread utilities */
#define MC_INFO_LABEL_DELIMITER ((const char *)(": "))
#define MC_INFO_LABEL_FW_VERSION ((const char *)("Firmware Revision"))
#define MC_INFO_LABEL_HW_VERSION ((const char *)("Device Revision"))
#define MC_INFO_LABEL_DEVICE_ID ((const char *)("Device ID"))
#define MC_INFO_LABEL_PRODUCT_ID ((const char *)("Product ID"))
#define MC_INFO_LABEL_PRODUCT_NAME ((const char *)("Product Name"))
#define MC_INFO_LABEL_MANUFACTURE_ID ((const char *)("Manufacturer ID"))
#define MC_INFO_LABEL_MANUFACTURE_NAME ((const char *)("Manufacturer Name"))
#include "bmcUtil.h" /* for ... mtce-common bmc utility header */
#define THREAD_NAME__BMC ((const char *)("bmc"))
#define IPMITOOL_PATH_AND_FILENAME ((const char *)("/usr/bin/ipmitool"))
#define IPMITOOL_OUTPUT_DIR ((const char *)("/var/run/bmc/ipmitool/"))
#define BMC_INFO_LABEL_DELIMITER ((const char *)(": "))
#define BMC_INFO_LABEL_FW_VERSION ((const char *)("Firmware Revision"))
#define BMC_INFO_LABEL_HW_VERSION ((const char *)("Device Revision"))
#define BMC_INFO_LABEL_DEVICE_ID ((const char *)("Device ID"))
#define BMC_INFO_LABEL_PRODUCT_ID ((const char *)("Product ID"))
#define BMC_INFO_LABEL_PRODUCT_NAME ((const char *)("Product Name"))
#define BMC_INFO_LABEL_MANUFACTURE_ID ((const char *)("Manufacturer ID"))
#define BMC_INFO_LABEL_MANUFACTURE_NAME ((const char *)("Manufacturer Name"))
#define IPMITOOL_POWER_RESET_CMD ((const char *)("chassis power reset"))
#define IPMITOOL_POWER_RESET_RESP ((const char *)("Chassis Power Control: Reset"))
@ -46,53 +49,14 @@
#define IPMITOOL_BOOTDEV_PXE_CMD ((const char *)("chassis bootdev pxe"))
#define IPMITOOL_BOOTDEV_PXE_RESP ((const char *)("Set Boot Device to pxe"))
#define IPMITOOL_MC_INFO_CMD ((const char *)("mc info"))
#define IPMITOOL_CMD_FILE_SUFFIX ((const char *)("_power_cmd_result"))
#define IPMITOOL_MC_INFO_FILE_SUFFIX ((const char *)("_mc_info"))
#define IPMITOOL_RESTART_CAUSE_FILE_SUFFIX ((const char *)("_restart_cause"))
#define IPMITOOL_POWER_STATUS_FILE_SUFFIX ((const char *)("_power_status"))
#define IPMITOOL_MAX_RECV_RETRIES (10)
/* Warning : Changes here require 'mtc_ipmiRequest_str' string array to be updated */
typedef enum
{
IPMITOOL_THREAD_CMD__NULL = 0,
IPMITOOL_THREAD_CMD__POWER_RESET,
IPMITOOL_THREAD_CMD__POWER_ON,
IPMITOOL_THREAD_CMD__POWER_OFF,
IPMITOOL_THREAD_CMD__POWER_CYCLE,
IPMITOOL_THREAD_CMD__MC_INFO,
IPMITOOL_THREAD_CMD__POWER_STATUS,
IPMITOOL_THREAD_CMD__RESTART_CAUSE,
IPMITOOL_THREAD_CMD__BOOTDEV_PXE,
IPMITOOL_THREAD_CMD__READ_SENSORS,
IPMITOOL_THREAD_CMD__LAST
} ipmitool_cmd_enum ;
const char * getIpmiCmd_str ( int command );
const char * getIpmiAction_str ( int command );
#define IPMITOOL_BMC_INFO_CMD ((const char *)("mc info"))
#define BMC__MAX_RECV_RETRIES (10)
typedef struct
{
std::string product_name ;
std::string product_id ;
std::string manufacturer_name ;
std::string manufacturer_id ;
std::string device_id ;
std::string fw_version ;
std::string hw_version ;
} mc_info_type ;
int ipmiUtil_init ( void );
int ipmiUtil_mc_info_load ( string hostname, const char * filename, mc_info_type & mc_info );
void ipmiUtil_mc_info_init ( mc_info_type & mc_info );
int ipmiUtil_bmc_info_load ( string hostname, const char * filename, bmc_info_type & mc_info );
void ipmiUtil_mc_info_init ( bmc_info_type & mc_info );
/* Create a randomly named password filename */
void ipmiUtil_create_pw_fn ( thread_info_type * info_ptr, string pw );

@ -153,10 +153,13 @@ void daemon_exit ( void );
#define BM_DNSMASQ_FILENAME ((const char *)"dnsmasq.bmc_hosts")
#define THREAD_NAME__IPMITOOL ((const char *)("ipmitool"))
/* supported BMC communication protocols ; access method */
typedef enum
{
BMC_PROTOCOL__IPMITOOL,
BMC_PROTOCOL__REDFISHTOOL,
} bmc_protocol_enum ;
#define IPMITOOL_PATH_AND_FILENAME ((const char *)("/usr/bin/ipmitool"))
#define IPMITOOL_OUTPUT_DIR ((const char *)("/var/run/ipmitool/"))
/** 'lo' interface IP address - TODO: get it from the interface */
#define LOOPBACK_IP "127.0.0.1"
@ -309,7 +312,7 @@ void daemon_exit ( void );
#define MTC_POWER_ACTION_RETRY_COUNT (10)
#define MTC_RESET_ACTION_RETRY_COUNT (5)
/* number of calls to the bm_handler while bm_access is not confirmed */
/* number of calls to the bmc_handler while bm_access is not confirmed */
#define MTC_MAX_B2B_BM_ACCESS_FAIL_COUNT_B4_ALARM (5)
/* string too long for inv */
#define MTC_TASK_DISABLE_REJ "Lock Rejected: Incomplete Migration" /* Please Enable More Worker Resources" */
@ -738,15 +741,6 @@ typedef struct
const char * get_mtcNodeCommand_str ( int cmd );
typedef enum
{
PROTOCOL__NONE = 0,
PROTOCOL__SMASH = 1,
PROTOCOL__IPMI = 2,
PROTOCOL__MAX = 3
} protocol_enum ;
/** Maintenance Commands used to specify HTTP REST API Command operations */
typedef enum
{

@ -89,6 +89,7 @@
#define SM_NOTIFY_UNHEALTHY_DELAY_SECS (5)
#define MTC_MIN_ONLINE_PERIOD_SECS (7)
#define MTC_RETRY_WAIT (5)
#define MTC_FIRST_WAIT (3)
#define MTC_AGENT_TIMEOUT_EXTENSION (5)
#define MTC_LOCK_CEPH_DELAY (90)

@ -0,0 +1,184 @@
/*
* Copyright (c) 2019 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*
*
*
* @file
* Starling-X Common Redfish Utilities
*/
#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;
#include "nodeBase.h" /* for ... mtce node common definitions */
#include "hostUtil.h" /* for ... mtce host common definitions */
#include "jsonUtil.h" /* for ... */
#include "redfishUtil.h" /* for ... this module header */
/*************************************************************************
*
* Name : redfishUtil_init
*
* Purpose : Module init
*
* Description: Initialize redfish tool utility module.
*
* Returns : Initialization result ; always PASS (for now)
*
*************************************************************************/
int redfishUtil_init ( void )
{
daemon_make_dir(REDFISHTOOL_OUTPUT_DIR) ;
return (PASS);
}
/*************************************************************************
*
* Name : redfishUtil_is_supported
*
* Purpose : Check for redfish supported response
*
* Description: A redfish root query response that indicates redfish
* protocol support includes the following key:value.
*
* "RedfishVersion": "1.0.1",
*
* Assumptions: Must support redfish version 1.x.x or higher.
*
* Parameters : The root query response string
*
* Returns : true if redfish is supported.
* false otherwise
*
*************************************************************************/
bool redfishUtil_is_supported (string & hostname, string & response)
{
if ( response.length() > strlen(REDFISH_LABEL__FW_VERSION ))
{
string redfish_version = "" ;
/* look for error ; stderro is directed to the datafile */
if ( response.find(REDFISHTOOL_RESPONSE_ERROR) != string::npos )
{
if ( response.find(REDFISHTOOL_ERROR_STATUS_CODE__NOT_FOUND) != string::npos )
{
ilog ("%s does not support Redfish platform management",
hostname.c_str());
}
else
{
wlog ("%s redfishtool %s: %s",
hostname.c_str(),
REDFISHTOOL_RESPONSE_ERROR,
response.c_str());
}
return (false) ;
}
/* if no error then look for the redfish version number */
if ( jsonUtil_get_key_val ((char*)response.data(),
REDFISH_LABEL__FW_VERSION,
redfish_version) == PASS )
{
if ( ! redfish_version.empty() )
{
int major = 0, minor = 0, revision = 0 ;
int fields = sscanf ( redfish_version.data(),
"%d.%d.%d",
&major,
&minor,
&revision );
if (( fields ) && ( major >= REDFISH_MIN_MAJOR_VERSION ))
{
ilog ("%s bmc redfish version %s (%d.%d.%d)",
hostname.c_str(),
redfish_version.c_str(),
major, minor, revision );
return true ;
}
else
{
ilog ("%s bmc has unsupported redfish version %s (%d:%d.%d.%d)",
hostname.c_str(),
redfish_version.c_str(),
fields, major, minor, revision );
ilog ("%s response: %s", hostname.c_str(), response.c_str()); // ERIK: make blog ?
}
}
else
{
wlog ("%s bmc failed to provide redfish version\n%s",
hostname.c_str(),
response.c_str());
}
}
else
{
wlog ("%s bmc redfish root query response has no '%s' label\n%s",
hostname.c_str(),
REDFISH_LABEL__FW_VERSION,
response.c_str());
}
}
else
{
ilog ("%s bmc does not support redfish",
hostname.c_str());
}
return false ;
}
/*************************************************************************
*
* Name : redfishUtil_create_request
*
* Purpose : create redfishtool command request
*
* Description: A command request involves command options / arguements
*
* -r ip - the ip address to send the request to
* -c config_file - the bmc cfgFile (password) filename
* cmd - the redfish command to execute
* > out - the filename to where the output is directed
*
* Returns : full command request as a single string
*
*************************************************************************/
string redfishUtil_create_request ( string cmd,
string & ip,
string & config_file,
string & out )
{
/* build the command ; starting with the redfishtool binary */
string command_request = REDFISHTOOL_PATH_AND_FILENAME ;
/* specify the bmc ip address */
command_request.append(" -r ");
command_request.append(ip);
/* add the config file option and config filename */
command_request.append(" -c ");
command_request.append(config_file);
/* add the command */
command_request.append(" ");
command_request.append(cmd);
/* output filename */
command_request.append (" > ");
command_request.append (out);
/* direct stderr to stdio */
command_request.append (" 2>&1");
return (command_request);
}

@ -0,0 +1,53 @@
#ifndef __INCLUDE_REDFISHUTIL_H__
#define __INCLUDE_REDFISHUTIL_H__
/*
* Copyright (c) 2017 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*
*/
/**
* @file
* Starling-X Common Redfish Utilities Header
*/
#include "bmcUtil.h" /* for ... mtce-common bmc utility header */
#define REDFISHTOOL_PATH_AND_FILENAME ((const char *)("/usr/bin/redfishtool"))
#define REDFISHTOOL_OUTPUT_DIR ((const char *)("/var/run/bmc/redfishtool/"))
#define REDFISH_LABEL__FW_VERSION ((const char *)("RedfishVersion"))
#define REDFISH_MIN_MAJOR_VERSION (1)
#define REDFISHTOOL_ROOT_QUERY_CMD ((const char *)("root"))
#define REDFISHTOOL_BMC_INFO_CMD ((const char *)("Systems get"))
#define REDFISHTOOL_POWER_RESET_CMD ((const char *)("Systems reset GracefulRestart"))
#define REDFISHTOOL_POWER_ON_CMD ((const char *)("Systems reset On"))
#define REDFISHTOOL_POWER_OFF_CMD ((const char *)("Systems reset ForceOff"))
#define REDFISHTOOL_BOOTDEV_PXE_CMD ((const char *)("Systems setBootOverride Once Pxe"))
/* no support response string
*
* redfishtool:Transport: Response Error: status_code: 404 -- Not Found
*
*/
#define REDFISHTOOL_RESPONSE_ERROR ((const char *)("Response Error"))
#define REDFISHTOOL_ERROR_STATUS_CODE__NOT_FOUND ((const char *)("status_code: 404"))
#define REDFISHTOOL_ERROR_STATUS_CODE__NOT_ALLOWED ((const char *)("status_code: 405"))
/* module init */
int redfishUtil_init ( void );
/* create a redfish tool thread request */
string redfishUtil_create_request ( string cmd,
string & ip,
string & config_file,
string & out );
/* interpret redfish root query response and check version */
bool redfishUtil_is_supported ( string & hostname, string & root_query_response );
#endif // __INCLUDE_REDFISHUTIL_H__

@ -131,37 +131,37 @@ using namespace std;
#define dlog_t(format, args...) { \
if(daemon_get_cfg_ptr()->debug_level&1) \
{ syslog(LOG_INFO, "[%ld.%05d] %s %s %-3s %-18s(%4d) %-24s:Debug : " format, gettid(), lc(), _hn(), _pn, __AREA__, __FILE__, __LINE__, __FUNCTION__, ##args) ; }}
{ syslog(LOG_INFO, "[%ld.%05d] %s %s %-3s %-18s(%4d) %-24s:debug : " format, gettid(), lc(), _hn(), _pn, __AREA__, __FILE__, __LINE__, __FUNCTION__, ##args) ; }}
#define dlog1_t(format, args...) { \
if(daemon_get_cfg_ptr()->debug_level&2) \
{ syslog(LOG_INFO, "[%ld.%05d] %s %s %-3s %-18s(%4d) %-24s:Debug2: " format, gettid(), lc(), _hn(), _pn, __AREA__, __FILE__, __LINE__, __FUNCTION__, ##args) ; }}
{ syslog(LOG_INFO, "[%ld.%05d] %s %s %-3s %-18s(%4d) %-24s:debug2: " format, gettid(), lc(), _hn(), _pn, __AREA__, __FILE__, __LINE__, __FUNCTION__, ##args) ; }}
#define dlog2_t(format, args...) { \
if(daemon_get_cfg_ptr()->debug_level&4) \
{ syslog(LOG_INFO, "[%ld.%05d] %s %s %-3s %-18s(%4d) %-24s:Debug4: " format, gettid(), lc(), _hn(), _pn, __AREA__, __FILE__, __LINE__, __FUNCTION__, ##args) ; }}
{ syslog(LOG_INFO, "[%ld.%05d] %s %s %-3s %-18s(%4d) %-24s:debug4: " format, gettid(), lc(), _hn(), _pn, __AREA__, __FILE__, __LINE__, __FUNCTION__, ##args) ; }}
#define dlog3_t(format, args...) { \
if(daemon_get_cfg_ptr()->debug_level&8) \
{ syslog(LOG_INFO, "[%ld.%05d] %s %s %-3s %-18s(%4d) %-24s:Debug8: " format, gettid(), lc(), _hn(), _pn, __AREA__, __FILE__, __LINE__, __FUNCTION__, ##args) ; }}
{ syslog(LOG_INFO, "[%ld.%05d] %s %s %-3s %-18s(%4d) %-24s:debug8: " format, gettid(), lc(), _hn(), _pn, __AREA__, __FILE__, __LINE__, __FUNCTION__, ##args) ; }}
#define blog_t(format, args...) { \
if(daemon_get_cfg_ptr()->debug_bmgmt&1) \
{ syslog(LOG_INFO, "[%ld.%05d] %s %s %-3s %-18s(%4d) %-24s: BMgt : " format, gettid(), lc(), _hn(), _pn, __AREA__, __FILE__, __LINE__, __FUNCTION__, ##args) ; }}
{ syslog(LOG_INFO, "[%ld.%05d] %s %s %-3s %-18s(%4d) %-24s: bmgt : " format, gettid(), lc(), _hn(), _pn, __AREA__, __FILE__, __LINE__, __FUNCTION__, ##args) ; }}
#define blog1_t(format, args...) { \
if(daemon_get_cfg_ptr()->debug_bmgmt&2) \
{ syslog(LOG_INFO, "[%ld.%05d] %s %s %-3s %-18s(%4d) %-24s: BMgt2: " format, gettid(), lc(), _hn(), _pn, __AREA__, __FILE__, __LINE__, __FUNCTION__, ##args) ; }}
{ syslog(LOG_INFO, "[%ld.%05d] %s %s %-3s %-18s(%4d) %-24s: bmgt2: " format, gettid(), lc(), _hn(), _pn, __AREA__, __FILE__, __LINE__, __FUNCTION__, ##args) ; }}
#define blog2_t(format, args...) { \
if(daemon_get_cfg_ptr()->debug_bmgmt&4) \
{ syslog(LOG_INFO, "[%ld.%05d] %s %s %-3s %-18s(%4d) %-24s: BMgt4: " format, gettid(), lc(), _hn(), _pn, __AREA__, __FILE__, __LINE__, __FUNCTION__, ##args) ; }}
{ syslog(LOG_INFO, "[%ld.%05d] %s %s %-3s %-18s(%4d) %-24s: bmgt4: " format, gettid(), lc(), _hn(), _pn, __AREA__, __FILE__, __LINE__, __FUNCTION__, ##args) ; }}
#define blog3_t(format, args...) { \
if(daemon_get_cfg_ptr()->debug_bmgmt&8) \
{ syslog(LOG_INFO, "[%ld.%05d] %s %s %-3s %-18s(%4d) %-24s: BMgt8: " format, gettid(), lc(), _hn(), _pn, __AREA__, __FILE__, __LINE__, __FUNCTION__, ##args) ; }}
{ syslog(LOG_INFO, "[%ld.%05d] %s %s %-3s %-18s(%4d) %-24s: bmgt8: " format, gettid(), lc(), _hn(), _pn, __AREA__, __FILE__, __LINE__, __FUNCTION__, ##args) ; }}
#define THREAD_INIT_SIG (0xbabef00d)
#define MAX_PTHREADS (1) /* max number concurrent pthreads */
#define DEFAULT_THREAD_TIMEOUT_SECS (60) /* default pthread exec timout */
#define MAX_LOG_PREFIX_LEN (MAX_CHARS_HOSTNAME*4)
#define MAX_LOG_PREFIX_LEN (MAX_CHARS_ON_LINE)
#define THREAD_POST_KILL_WAIT (10) /* wait time between KILL and IDLE */
typedef enum
@ -199,7 +199,7 @@ typedef struct
int timeout ; /* timout in msecs , 0 for no timeout */
/* FSM Level Completion Control and Status */
int status ; /* FSM status ; overrides info status */
unsigned int status ; /* FSM status ; overrides info status */
bool done ; /* flag indicating thread data was consumed */
int runcount ; /* copy of info.runcount before launch ; */
int retries ; /* max thread retries */
@ -228,7 +228,7 @@ typedef struct
string hostname ; /* hostname this thread is tied to */
string name ; /* short name of the thread */
int command ; /* the command the thread should execute */
int command ; /* the command the thread should execute */
int signal ; /* parent request signal ; SIGKILL exit request */
void * extra_info_ptr ; /* pointer to thread specific command data */
char log_prefix[MAX_LOG_PREFIX_LEN]; /* preformatted log prefix */
@ -238,7 +238,7 @@ typedef struct
/* -------------------------------------------------------------------- */
pthread_t id ; /* the thread id of self */
int status ; /* thread execution status set before runcount++ */
int unsigned status ; /* thread execution status set before runcount++ */
string status_string ; /* status string representing unique error case */
int runcount ; /* thread increments just before exit - complete */
int progress ; /* incremented by thread ; show forward progress */
@ -247,6 +247,8 @@ typedef struct
int pw_file_fd ; /* file descriptor for the password file */
string password_file ; /* the name of the password file */
bmc_protocol_enum proto ; /* IPMITOOL, REDFISHTOOL, future ... */
} thread_info_type ;
/****************************************************************************/

@ -66,6 +66,7 @@ Requires: libpthread.so.0()(64bit)
Requires: /usr/bin/expect
Requires: python-rtslib
Requires: /usr/bin/ipmitool
Requires: /usr/bin/redfishtool
%description
Titanium Cloud Host Maintenance services. A suite of daemons that provide
@ -167,7 +168,7 @@ Requires: libgcc_s.so.1()(64bit)
Requires: libstdc++.so.6(GLIBCXX_3.4)(64bit)
Requires: libstdc++.so.6(GLIBCXX_3.4.15)(64bit)
Requires: libpthread.so.0()(64bit)
Requires: /usr/bin/ipmitool
Requires: /usr/bin/redfishtool
%description -n mtce-hwmon
Titanium Cloud Host Maintenance Hardware Monitor Service (hwmond) adds

@ -631,12 +631,13 @@ nodeLinkClass::node* nodeLinkClass::addNode( string hostname )
ptr->mnfa_graceful_recovery = false ;
/* initialize all board management variables for this host */
ptr->bmc_protocol = BMC_PROTOCOL__IPMITOOL ;
ptr->bm_ip = NONE ;
ptr->bm_type = NONE ;
ptr->bm_un = NONE ;
ptr->bm_pw = NONE ;
ptr->bm_provisioned = false ; /* assume not provisioned until learned */
ptr->bmc_provisioned = false ; /* assume not provisioned until learned */
ptr->power_on = false ; /* learned on first BMC connection */
bmc_access_data_init ( ptr ); /* init all the BMC access vars all modes */
@ -1889,7 +1890,7 @@ int nodeLinkClass::del_host ( const string uuid )
if ( nodeLinkClass::maintenance == true )
{
if ( node_ptr->bm_provisioned == true )
if ( node_ptr->bmc_provisioned == true )
{
set_bm_prov ( node_ptr, false);
}
@ -2182,7 +2183,7 @@ int nodeLinkClass::mod_host ( node_inv_type & inv )
* - its in progress,
* - there is a BMC provisioned and
* - are waiting while the actual install is in progress */
if (( node_ptr->bm_provisioned == true ) &&
if (( node_ptr->bmc_provisioned == true ) &&
( node_ptr->reinstallStage == MTC_REINSTALL__ONLINE_WAIT))
{
reinstallStageChange ( node_ptr , MTC_REINSTALL__START );
@ -2742,13 +2743,13 @@ int nodeLinkClass::add_host ( node_inv_type & inv )
node_ptr->bm_ping_info.sock = 0 ;
/* initialize the host power and reset control thread */
thread_init ( node_ptr->ipmitool_thread_ctrl,
node_ptr->ipmitool_thread_info,
thread_init ( node_ptr->bmc_thread_ctrl,
node_ptr->bmc_thread_info,
&node_ptr->thread_extra_info,
mtcThread_ipmitool,
mtcThread_bmc,
DEFAULT_THREAD_TIMEOUT_SECS,
node_ptr->hostname,
THREAD_NAME__IPMITOOL);
THREAD_NAME__BMC);
if ( adminStateOk (inv.admin) &&
operStateOk (inv.oper ) &&
@ -3922,7 +3923,7 @@ int nodeLinkClass::manage_bmc_provisioning ( struct node * node_ptr )
{
int rc = PASS ;
bool was_provisioned = node_ptr->bm_provisioned ;
bool was_provisioned = node_ptr->bmc_provisioned ;
set_bm_prov ( node_ptr, false);
if ((hostUtil_is_valid_ip_addr ( node_ptr->bm_ip )) &&
@ -3949,7 +3950,7 @@ int nodeLinkClass::manage_bmc_provisioning ( struct node * node_ptr )
ilog ("%s sending board management info update to hwmond\n", node_ptr->hostname.c_str() );
if ( ( rc = send_hwmon_command(node_ptr->hostname,MTC_CMD_MOD_HOST) ) == PASS )
{
if ( node_ptr->bm_provisioned == true )
if ( node_ptr->bmc_provisioned == true )
{
rc = send_hwmon_command(node_ptr->hostname,MTC_CMD_START_HOST);
}
@ -4007,7 +4008,7 @@ int nodeLinkClass::set_bm_type ( string hostname , string bm_type )
int nodeLinkClass::set_bm_un ( string hostname , string bm_un )
{
int rc = FAIL_HOSTNAME_LOOKUP ;
nodeLinkClass::node* node_ptr ;
node_ptr = nodeLinkClass::getNode ( hostname );
if ( node_ptr != NULL )
@ -4020,9 +4021,9 @@ int nodeLinkClass::set_bm_un ( string hostname , string bm_un )
{
node_ptr->bm_un = NONE ;
}
dlog ("%s '%s' updated to '%s'\n",
hostname.c_str(),
MTC_JSON_INV_BMUN,
dlog ("%s '%s' updated to '%s'\n",
hostname.c_str(),
MTC_JSON_INV_BMUN,
node_ptr->bm_un.c_str());
rc = PASS ;
}
@ -4032,16 +4033,16 @@ int nodeLinkClass::set_bm_un ( string hostname , string bm_un )
int nodeLinkClass::set_bm_ip ( string hostname , string bm_ip )
{
int rc = FAIL_HOSTNAME_LOOKUP ;
nodeLinkClass::node* node_ptr ;
node_ptr = nodeLinkClass::getNode ( hostname );
if ( node_ptr != NULL )
{
node_ptr->bm_ip = bm_ip ;
dlog ("%s '%s' updated to '%s'\n",
hostname.c_str(),
MTC_JSON_INV_BMIP,
dlog ("%s '%s' updated to '%s'\n",
hostname.c_str(),
MTC_JSON_INV_BMIP,
node_ptr->bm_ip.c_str());
rc = PASS ;
}
@ -4052,13 +4053,18 @@ void nodeLinkClass::bmc_access_data_init ( struct nodeLinkClass::node * node_ptr
{
if ( node_ptr )
{
node_ptr->bm_accessible = false;
node_ptr->mc_info_query_active = false ;
node_ptr->mc_info_query_done = false ;
node_ptr->reset_cause_query_active = false ;
node_ptr->reset_cause_query_done = false ;
node_ptr->power_status_query_active = false;
node_ptr->power_status_query_done = false ;
node_ptr->bmc_accessible = false ;
node_ptr->bm_ping_info.ok = false ;
node_ptr->bmc_info_query_active = false ;
node_ptr->bmc_info_query_done = false ;
node_ptr->reset_cause_query_active = false ;
node_ptr->reset_cause_query_done = false ;
node_ptr->power_status_query_active = false ;
node_ptr->power_status_query_done = false ;
node_ptr->bmc_protocol_learned = false ;
node_ptr->bmc_protocol_learning = false ;
node_ptr->bmc_protocol = BMC_PROTOCOL__IPMITOOL ;
bmcUtil_info_init ( node_ptr->bmc_info );
}
}
@ -4080,20 +4086,24 @@ int nodeLinkClass::set_bm_prov ( struct nodeLinkClass::node * node_ptr, bool sta
int rc = FAIL_HOSTNAME_LOOKUP ;
if ( node_ptr != NULL )
{
ilog ("%s bmc %sprovision request (provisioned:%s)\n", // ERIC blog
/* default the bmc info file */
string bmc_info_path_n_filename = BMC_OUTPUT_DIR + node_ptr->hostname ;
ilog ("%s bmc %sprovision request (provisioned:%s)\n",
node_ptr->hostname.c_str(),
state ? "" : "de",
<