From 985ad5edc051761eeeaf1659fbe2518ecc391ee1 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Thu, 13 Aug 2020 14:38:05 -0400 Subject: [PATCH] Warn if fencing will fail Verify our IPMI state on startup, and then warn if fencing will fail. For now, this is sufficient, but in future (requires refactoring) we might want to adjust how fencing occurs based on this information. --- node-daemon/pvcnoded/Daemon.py | 8 +++++++- node-daemon/pvcnoded/fencing.py | 13 +++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/node-daemon/pvcnoded/Daemon.py b/node-daemon/pvcnoded/Daemon.py index e01229a5..ad12593c 100644 --- a/node-daemon/pvcnoded/Daemon.py +++ b/node-daemon/pvcnoded/Daemon.py @@ -693,7 +693,13 @@ else: zkhandler.writedata(zk_conn, { '/primary_node': myhostname }) ############################################################################### -# PHASE 7 - Ensure Libvirt is working +# PHASE 7a - Ensure IPMI is reachable and working +############################################################################### +if not fencing.verifyIPMI(config['ipmi_hostname'], config['ipmi_username'], config['ipmi_password']): + logger.out('Our IPMI is not reachable; fencing of this node will likely fail', state='w') + +############################################################################### +# PHASE 7b - Ensure Libvirt is working ############################################################################### if enable_hypervisor: diff --git a/node-daemon/pvcnoded/fencing.py b/node-daemon/pvcnoded/fencing.py index 93fbb619..e58cc22d 100644 --- a/node-daemon/pvcnoded/fencing.py +++ b/node-daemon/pvcnoded/fencing.py @@ -144,3 +144,16 @@ def rebootViaIPMI(ipmi_hostname, ipmi_user, ipmi_password, logger): logger.out('Failed to reboot dead node', state='e') print(ipmi_reset_stderr) return False + +# +# Verify that IPMI connectivity to this host exists (used during node init) +# +def verifyIPMI(ipmi_hostname, ipmi_user, ipmi_password): + ipmi_command_status = '/usr/bin/ipmitool -I lanplus -H {} -U {} -P {} chassis power status'.format( + ipmi_hostname, ipmi_user, ipmi_password + ) + ipmi_status_retcode, ipmi_status_stdout, ipmi_status_stderr = common.run_os_command(ipmi_command_status, timeout=2) + if ipmi_status_retcode == 0 and ipmi_status_stdout != "Chassis Power is on": + return True + else: + return False