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