diff --git a/mtce-common/src/common/nodeBase.h b/mtce-common/src/common/nodeBase.h index 8af83c3b..38a188d7 100755 --- a/mtce-common/src/common/nodeBase.h +++ b/mtce-common/src/common/nodeBase.h @@ -66,7 +66,7 @@ void daemon_exit ( void ); #define FAIL_BM_IPADDR (121*256) #define FAIL_BM_PASSWORD (122*256) - +#define MTC_PARM_LOCK_PERSIST_IDX (0) // node lock command #define MTC_PARM_UPTIME_IDX (0) #define MTC_PARM_HEALTH_IDX (1) #define MTC_PARM_FLAGS_IDX (2) @@ -110,6 +110,7 @@ void daemon_exit ( void ); #define SMGMT_DEGRADED_FILE ((const char *)"/var/run/.sm_degraded") #define SMGMT_UNHEALTHY_FILE ((const char *)"/var/run/.sm_node_unhealthy") #define UNLOCK_READY_FILE ((const char *)"/etc/platform/.unlock_ready") +#define STILL_SIMPLEX_FILE ((const char *)"/etc/platform/simplex") /** path to and module init file name */ #define MTCE_CONF_FILE ((const char *)"/etc/mtc.conf") diff --git a/mtce/src/maintenance/mtcCompMsg.cpp b/mtce/src/maintenance/mtcCompMsg.cpp index ba6049ba..446f1f53 100755 --- a/mtce/src/maintenance/mtcCompMsg.cpp +++ b/mtce/src/maintenance/mtcCompMsg.cpp @@ -237,13 +237,20 @@ int mtc_service_command ( mtc_socket_type * sock_ptr, int interface ) daemon_log ( NODE_LOCKED_FILE, ADMIN_LOCKED_STR); } - /* Preserve the node locked state in a non-volatile backup - * file that persists over reboot. - * Maintaining the legacy NODE_LOCKED_FILE as other sw looks at it. */ - if ( daemon_is_file_present ( NODE_LOCKED_FILE_BACKUP ) == false ) + /* Only create the non-volatile NODE_LOCKED_FILE_BACKUP file if the + * LOCK_PERSIST flag is present. */ + if ( msg.num && msg.parm[MTC_PARM_LOCK_PERSIST_IDX] ) { - daemon_log ( NODE_LOCKED_FILE_BACKUP, ADMIN_LOCKED_STR ); + /* Preserve the node locked state in a non-volatile backup + * file that persists over reboot. + * Maintaining the legacy NODE_LOCKED_FILE as other sw looks at it. */ + if ( daemon_is_file_present ( NODE_LOCKED_FILE_BACKUP ) == false ) + daemon_log ( NODE_LOCKED_FILE_BACKUP, ADMIN_LOCKED_STR ); } + /* Otherwise if we get a locked message without the LOCK_PERSIST flag + * then remove the non-volatile NODE_LOCKED_FILE_BACKUP file if exists */ + else if ( daemon_is_file_present ( NODE_LOCKED_FILE_BACKUP ) == true ) + daemon_remove_file ( NODE_LOCKED_FILE_BACKUP ); } else if ( msg.cmd == MTC_MSG_UNLOCKED ) { diff --git a/mtce/src/maintenance/mtcCtrlMsg.cpp b/mtce/src/maintenance/mtcCtrlMsg.cpp index 69fef347..1b1ccb5c 100755 --- a/mtce/src/maintenance/mtcCtrlMsg.cpp +++ b/mtce/src/maintenance/mtcCtrlMsg.cpp @@ -717,6 +717,20 @@ int send_mtc_cmd ( string & hostname, int cmd , int interface, string json_dict snprintf ( &mtc_cmd.hdr[0], MSG_HEADER_SIZE, "%s", get_cmd_req_msg_header() ); mtc_cmd.cmd = cmd ; mtc_cmd.num = 0 ; + /* Only set the LOCK_PERSIST flag if the STILL_SIMPLEX_FILE + * is no longer present. + * + * The mtcClient will NOT create the non-volatile + * NODE_LOCKED_FILE_BACKUP file if the LOCK_PERSIST flag + * is missing. + * + * This way SM won't shutdown or prevent activating on a + * locked controller until the system is truely duplex. */ + if ( daemon_is_file_present ( STILL_SIMPLEX_FILE ) == false ) + { + mtc_cmd.num = 1 ; + mtc_cmd.parm[MTC_PARM_LOCK_PERSIST_IDX] = true ; + } rc = PASS ; break ; }