Esempio n. 1
0
 def do_stop(self, context):
     '''
     Stops the cluster services on this node
     '''
     rc, out, err = utils.get_stdout_stderr('service pacemaker stop')
     if rc != 0:
         context.fatal_error("Failed to stop pacemaker service: %s" % (err))
     rc, out, err = utils.get_stdout_stderr('service corosync stop')
     if rc != 0:
         context.fatal_error("Failed to stop corosync service: %s" % (err))
     err_buf.info("Cluster services stopped")
Esempio n. 2
0
 def do_stop(self, context):
     '''
     Stops the cluster services on this node
     '''
     rc, out, err = utils.get_stdout_stderr('service pacemaker stop')
     if rc != 0:
         context.fatal_error("Failed to stop pacemaker service: %s" % (err))
     rc, out, err = utils.get_stdout_stderr('service corosync stop')
     if rc != 0:
         context.fatal_error("Failed to stop corosync service: %s" % (err))
     err_buf.info("Cluster services stopped")
Esempio n. 3
0
def run(name, args):
    '''
    Run the given script on the given set of hosts
    name: a cluster script is a folder <name> containing a main.yml file
    args: list of nvpairs
    '''
    if not has_pssh:
        try:
            from psshlib.task import Task
        except ImportError:
            raise ValueError("The pssh library is not installed or is not up to date.")
        raise ValueError("The installed pssh library lacks the API patch.")
    workdir = _generate_workdir_name()
    main, filename, script_dir = _open_script(name)
    params = _parse_parameters(name, args, main)
    hosts = params['nodes']
    err_buf.info(main['name'])
    err_buf.info("Nodes: " + ', '.join([x[0] for x in hosts]))
    local_node, hosts = _extract_localnode(hosts)
    opts = _make_options(params)
    _set_controlpersist(opts)

    try:
        _create_script_workdir(script_dir, workdir)
        _copy_utils(workdir)
        _create_remote_workdirs(hosts, workdir, opts)
        _copy_to_remote_dirs(hosts, workdir, opts)
        # make sure all path references are relative to the script directory
        os.chdir(workdir)

        stepper = RunStep(main, params, local_node, hosts, opts, workdir)
        step = params['step']
        statefile = params['statefile']
        if step or statefile:
            if not step or not statefile:
                raise ValueError("Must set both step and statefile")
            return stepper.single_step(step, statefile)
        else:
            return stepper.all_steps()

    except (OSError, IOError), e:
        import traceback
        traceback.print_exc()
        raise ValueError("Internal error while running %s: %s" % (name, e))
Esempio n. 4
0
def run(name, args):
    '''
    Run the given script on the given set of hosts
    name: a cluster script is a folder <name> containing a main.yml file
    args: list of nvpairs
    '''
    if not has_pssh:
        raise ValueError(
            "The parallax library is not installed or is not up to date.")
    workdir = _generate_workdir_name()
    main, filename, script_dir = _open_script(name)
    params = _parse_parameters(name, args, main)
    hosts = params['nodes']
    err_buf.info(main['name'])
    err_buf.info("Nodes: " + ', '.join([x[0] for x in hosts]))
    local_node, hosts = _extract_localnode(hosts)
    opts = _make_options(params)
    _set_controlpersist(opts)

    try:
        _create_script_workdir(script_dir, workdir)
        _copy_utils(workdir)
        _create_remote_workdirs(hosts, workdir, opts)
        _copy_to_remote_dirs(hosts, workdir, opts)
        # make sure all path references are relative to the script directory
        os.chdir(workdir)

        stepper = RunStep(main, params, local_node, hosts, opts, workdir)
        step = params['step']
        statefile = params['statefile']
        if step or statefile:
            if not step or not statefile:
                raise ValueError("Must set both step and statefile")
            return stepper.single_step(step, statefile)
        else:
            return stepper.all_steps()

    except (OSError, IOError), e:
        import traceback
        traceback.print_exc()
        raise ValueError("Internal error while running %s: %s" % (name, e))
Esempio n. 5
0
def rename_rscref(c_obj, old_id, new_id):
    if rename_rscref_simple(c_obj, old_id, new_id) or \
            rename_rscref_rset(c_obj, old_id, new_id):
        err_buf.info("resource references in %s updated" % str(c_obj))
Esempio n. 6
0
def rename_rscref(c_obj, old_id, new_id):
    if rename_rscref_simple(c_obj, old_id, new_id) or \
            rename_rscref_rset(c_obj, old_id, new_id):
        err_buf.info("resource references in %s updated" % str(c_obj))