예제 #1
0
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()
예제 #2
0
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()
예제 #3
0
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()
예제 #4
0
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()
예제 #5
0
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()
예제 #6
0
def stopPacemaker(host):
    stop_service = raw_input("    Stop pacemaker service on %s? (y/n)" %
                             host.fqdn).lower()
    if stop_service in ['y', 'yes']:
        print "    Stopping pacemaker on %s" % host.fqdn

        try:
            shell.try_remote_command(host.fqdn, 'service pacemaker stop')
        except Exception as e:
            print "    Could not stop pacemaker on %s: %s" % (host.fqdn, e)
            try_again = raw_input("    Try again? (y/n)").lower()
            if try_again in ['y', 'yes']:
                stopPacemaker(host)
예제 #7
0
def startCorosync(host):
    start_service = raw_input("    Start corosync service on %s? (y/n)" %
                              host.fqdn).lower()
    if start_service in ['y', 'yes']:
        print "    Starting corosync on %s" % host.fqdn

        try:
            shell.try_remote_command(host.fqdn, 'service corosync start')
        except Exception as e:
            print "    Could not start corosync on %s: %s" % (host.fqdn, e)
            try_again = raw_input("    Try again? (y/n)").lower()
            if try_again in ['y', 'yes']:
                startCorosync(host)