133da10b08
This change enables one way communication via BMC (if configured) through mtce. when 2 controllers lost all communications to each other. The algorithm is: when communications all lost, both active and standby controllers, verify its interfaces (mgmt, infra, and oam) if active controller is healthy, it will request a bmc reset thorugh mtce, against standby controller. if standby controller is healthy, it will active itself and wait a total 45 seconds before requesting a bmc reset through mtce, against the active controller. Changes also include: 1. adding new initial failover state. initial state is a state before the node is enabled 2. remove failover thread. using worker thread action to perform time consuming operations 3. remove entire failover action table Story: 2003577 Task: 24901 Change-Id: I7d294d40e84469df6b6a6f6dd490cf3c4557b711 Signed-off-by: Bin Qian <bin.qian@windriver.com>
79 lines
2.1 KiB
C++
79 lines
2.1 KiB
C++
//
|
|
// Copyright (c) 2018 Wind River Systems, Inc.
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
#ifndef __SM_FAILOVER_FSM_H__
|
|
#define __SM_FAILOVER_FSM_H__
|
|
#include "sm_types.h"
|
|
|
|
typedef int SmFSMEventDataTypeT;
|
|
|
|
class ISmFSMEventData
|
|
{
|
|
public:
|
|
virtual SmFSMEventDataTypeT get_event_data_type() const = 0;
|
|
};
|
|
|
|
class SmFailoverFSM;
|
|
|
|
class SmFSMState
|
|
{
|
|
public:
|
|
SmFSMState(SmFailoverFSM& fsm) : fsm(fsm) {};
|
|
virtual ~SmFSMState(){};
|
|
virtual SmErrorT enter_state();
|
|
virtual SmErrorT exit_state();
|
|
protected:
|
|
SmFailoverFSM& fsm;
|
|
virtual SmErrorT event_handler(SmFailoverEventT event, const ISmFSMEventData* event_data)=0;
|
|
friend SmFailoverFSM;
|
|
};
|
|
|
|
class SmFailoverFSM
|
|
{
|
|
public:
|
|
SmFailoverFSM();
|
|
virtual ~SmFailoverFSM();
|
|
|
|
SmErrorT send_event(SmFailoverEventT event, const ISmFSMEventData* event_data);
|
|
|
|
SmErrorT register_fsm_state(SmFailoverStateT state, SmFSMState* state_handler);
|
|
|
|
SmErrorT set_state(SmFailoverStateT state);
|
|
inline SmFailoverStateT get_state() const {return this->_current_state;}
|
|
|
|
static SmErrorT initialize();
|
|
static SmErrorT finalize();
|
|
inline static SmFailoverFSM& get_fsm() {
|
|
return _the_fsm;
|
|
}
|
|
|
|
private:
|
|
static const int MaxState = SM_FAILOVER_STATE_MAX;
|
|
SmFSMState* _state_handlers[MaxState];
|
|
SmFailoverStateT _current_state;
|
|
|
|
static SmFailoverFSM _the_fsm;
|
|
SmErrorT init_state();
|
|
void deregister_states();
|
|
};
|
|
|
|
class SmIFStateChangedEventData: public ISmFSMEventData
|
|
{
|
|
public:
|
|
static const SmFSMEventDataTypeT SmIFStateChangedEventDataType = 2;
|
|
SmFSMEventDataTypeT get_event_data_type() const;
|
|
SmIFStateChangedEventData();
|
|
void set_interface_state(
|
|
SmInterfaceTypeT interface_type, SmFailoverInterfaceStateT interface_state);
|
|
SmFailoverInterfaceStateT get_interface_state(SmInterfaceTypeT interface_type) const;
|
|
|
|
private:
|
|
SmFailoverInterfaceStateT _mgmt_state;
|
|
SmFailoverInterfaceStateT _infra_state;
|
|
SmFailoverInterfaceStateT _oam_state;
|
|
};
|
|
|
|
#endif //__SM_FAILOVER_FSM_H__
|