def __setMaintenanceMode(host, mode): try: print " Setting maintenance mode to %s on %s." % (mode, host.fqdn) cmd = "pcs property set maintenance-mode=%s" % mode shell.try_remote_command(host.fqdn, cmd) except Exception as e: print " Could not set the cluster to standby mode: %s" % e shell.cont()
def applyNewPacemakerConfig(host, new_cib_location): try: print " Applying new pacemaker config." shell.try_remote_command( host.fqdn, "cibadmin --replace --xml-file %s" % new_cib_location) except Exception as e: print " Could not apply updated pacemaker configuration: %s" % e shell.cont()
def __setAgentState(host, action): try: print " %s the agent on %s." % (action, host.fqdn) cmd = "service chroma-agent %s" % action shell.try_remote_command(host.fqdn, cmd) except Exception as e: print " Could not stop the agent: %s" % e shell.cont()
def backupCurrentPacemakerConfig(host): try: print " Backing up pacemaker config on %s" % host.fqdn ts = int(time.time()) cmd = "cibadmin --query > /tmp/pacemaker_backup_%s" % ts shell.try_remote_command(host.fqdn, cmd) except Exception as e: print " Could not backup the pacemaker config: %s" % e shell.cont()
def updatePacemakerConfig(host, cib, new_cib_location): try: print " Copying %s to /tmp/selected_cib.xml and incrementing \ both epoch and admin epoch." % cib shell.try_remote_command( host.fqdn, """cat %s | sed "s/\\"/@@/g" | sed -r "s/(^<cib.+)(epoch=@@)([0-9]+)(.+)(admin_epoch=@@)([0-9]+)(.+)(>$)/echo \\"\\1\\2\\$((\\3+1))\\4\\5\\$((\\6+1))\\7\\8\\"/ge" | sed "s/@@/\\"/g" > %s""" % (cib, new_cib_location) # noqa E501 ) except Exception as e: print " Could not copy %s to %s. %s" % (cib, new_cib_location, e) shell.cont()