Example #1
0
def start(action):
    args = ""
    # find host, write deployment
    hoststring = ""
    if "hoststring" in CONFIG.data:
        hoststring = CONFIG.data["hoststring"]

    hosts = hoststring.split(",")
    hostcount = len(hosts)
    if not deployment.writedeploymentfile(
        CONFIG.data["deployment"], CONFIG.dataroot + buildinstancedir(CONFIG.id) + "/deployment.xml", hostcount
    ):
        # IF we can't write the deployment file, must fail.
        CONFIG.status = 0
        CONFIG.msg = deployment.getmessage()
        return currentResponse()

    putTextFile(CONFIG.dataroot + buildinstancedir(CONFIG.id) + "/CLUSTER", hoststring)

    action = action.strip().lower()
    if (action == "create") or (action == "recover"):
        if len(hosts) > 1:
            # Add leader
            args = args + " --host=" + hosts[0]
            args = args + " --deployment=deployment.xml"

    # start process
    detachable.start(action, args, CONFIG.dataroot + buildinstancedir(1))
    CONFIG.timestamp = CONFIG.timestamp + 1
    CONFIG.status = detachable.STATE.status
    CONFIG.msg = detachable.geterrors()
    putIntFile(CONFIG.dataroot + buildinstancedir(CONFIG.id) + "/STATUS", CONFIG.status)
    return currentResponse()
Example #2
0
def stop():
    # stop the current process. This should only be called
    # because the other nodes of the cluster could not start.
    detachable.kill()
    CONFIG.timestamp = CONFIG.timestamp + 1
    CONFIG.status = detachable.STATE.status
    CONFIG.msg = detachable.geterrors()
    return currentResponse()
Example #3
0
def stop():
    # stop the current process. This should only be called
    # because the other nodes of the cluster could not start.
    detachable.kill()
    CONFIG.timestamp = CONFIG.timestamp + 1
    CONFIG.status = detachable.STATE.status
    CONFIG.msg = detachable.geterrors()
    return currentResponse()
Example #4
0
def ping():
    newstatus = detachable.ping()
    if newstatus != CONFIG.status:
        DEBUG("Ping changing status from " + str(CONFIG.status) + " to " + str(newstatus))
        CONFIG.status = newstatus
        CONFIG.msg = detachable.geterrors()
        CONFIG.timestamp = CONFIG.timestamp + 1
        putIntFile(CONFIG.dataroot + buildinstancedir(CONFIG.id) + "/STATUS", newstatus)
    return currentResponse()
Example #5
0
def ping():
    newstatus = detachable.ping()
    if newstatus != CONFIG.status:
        DEBUG("Ping changing status from " + str(CONFIG.status) + " to " +
              str(newstatus))
        CONFIG.status = newstatus
        CONFIG.msg = detachable.geterrors()
        CONFIG.timestamp = CONFIG.timestamp + 1
        putIntFile(CONFIG.dataroot + buildinstancedir(CONFIG.id) + "/STATUS",
                   newstatus)
    return currentResponse()
Example #6
0
def start(action):
    args = ""
    # find host, write deployment
    hoststring = ""
    if "hoststring" in CONFIG.data: hoststring = CONFIG.data["hoststring"]

    hosts = hoststring.split(",")
    hostcount = len(hosts)
    if not deployment.writedeploymentfile( \
                CONFIG.data["deployment"], \
                CONFIG.dataroot + buildinstancedir(CONFIG.id) + "/deployment.xml", \
                hostcount):
        # IF we can't write the deployment file, must fail.
        CONFIG.status = 0
        CONFIG.msg = deployment.getmessage()
        return currentResponse()

    putTextFile(CONFIG.dataroot + buildinstancedir(CONFIG.id) + "/CLUSTER",
                hoststring)

    action = action.strip().lower()
    if (action == "create") or \
       (action == "recover"):
        if len(hosts) > 1:
            # Add leader
            args = args + " --host=" + hosts[0]
            args = args + " --deployment=deployment.xml"

    # start process
    detachable.start(action, args, CONFIG.dataroot + buildinstancedir(1))
    CONFIG.timestamp = CONFIG.timestamp + 1
    CONFIG.status = detachable.STATE.status
    CONFIG.msg = detachable.geterrors()
    putIntFile(CONFIG.dataroot + buildinstancedir(CONFIG.id) + "/STATUS",
               CONFIG.status)
    return currentResponse()