Beispiel #1
0
def run_copy():
    try:
        import parallax
    except ImportError:
        crm_script.exit_fail("Command node needs parallax installed")
    opts = make_opts()
    has_auth = os.path.isfile(COROSYNC_AUTH)
    if has_auth:
        results = parallax.copy(add_nodes, COROSYNC_AUTH, COROSYNC_AUTH, opts)
        check_results(parallax, results)
        results = parallax.call(
            add_nodes,
            "chown root:root %s;chmod 400 %s" % (COROSYNC_AUTH, COROSYNC_AUTH),
            opts)
        check_results(parallax, results)

    # Add new nodes to corosync.conf before copying
    for node in add_nodes:
        rc, _, err = crm_script.call(['crm', 'corosync', 'add-node', node])
        if rc != 0:
            crm_script.exit_fail('Failed to add %s to corosync.conf: %s' %
                                 (node, err))

    results = parallax.copy(add_nodes, COROSYNC_CONF, COROSYNC_CONF, opts)
    check_results(parallax, results)

    # reload corosync config here?
    rc, _, err = crm_script.call(['crm', 'corosync', 'reload'])
    if rc != 0:
        crm_script.exit_fail('Failed to reload corosync configuration: %s' %
                             (err))

    crm_script.exit_ok(host)
Beispiel #2
0
def push_configuration(nodes):
    '''
    Push the local configuration to the list of remote nodes
    '''
    try:
        import parallax as pssh
        _has_pssh = True
    except ImportError:
        _has_pssh = False

    if not _has_pssh:
        raise ValueError("PSSH is required to push")

    local_path = conf()

    opts = pssh.Options()
    opts.timeout = 60
    opts.ssh_options += ['ControlPersist=no']
    ok = True
    for host, result in pssh.copy(nodes, local_path, local_path,
                                  opts).iteritems():
        if isinstance(result, pssh.Error):
            err_buf.error("Failed to push configuration to %s: %s" %
                          (host, result))
            ok = False
        else:
            err_buf.ok(host)
    return ok
Beispiel #3
0
def run_copy():
    try:
        import parallax
    except ImportError:
        crm_script.exit_fail("Command node needs parallax installed")
    opts = make_opts()
    results = parallax.copy(others, COROSYNC_AUTH, COROSYNC_AUTH, opts)
    check_results(parallax, results)
    results = parallax.call(others,
                        "chown root:root %s;chmod 400 %s" % (COROSYNC_AUTH, COROSYNC_AUTH),
                        opts)
    check_results(parallax, results)
Beispiel #4
0
def run_copy():
    try:
        import parallax as pssh
    except ImportError:
        crm_script.exit_fail("Command node needs parallax installed")
    opts = make_opts()
    results = pssh.copy(others, COROSYNC_AUTH, COROSYNC_AUTH, opts)
    check_results(pssh, results)
    results = pssh.call(others,
                        "chown root:root %s;chmod 400 %s" % (COROSYNC_AUTH, COROSYNC_AUTH),
                        opts)
    check_results(pssh, results)
Beispiel #5
0
    def testCopyFile(self):
        opts = para.Options()
        opts.default_user = g_user
        opts.localdir = self.tmpDir
        by_host = para.copy(g_hosts, "/etc/hosts", "/tmp/para.test", opts)
        for host, result in by_host.items():
            if isinstance(result, para.Error):
                raise result
            rc, _, _ = result
            self.assertEqual(rc, 0)

        by_host = para.slurp(g_hosts, "/tmp/para.test", "para.test", opts)
        for host, result in by_host.items():
            if isinstance(result, para.Error):
                raise result
            rc, _, _, path = result
            self.assertEqual(rc, 0)
            self.assert_(path.endswith('%s/para.test' % (host)))
Beispiel #6
0
def cluster_copy_file(local_path, nodes=None):
    """
    Copies given file to all other cluster nodes.
    """
    try:
        import parallax
    except ImportError:
        raise ValueError("parallax is required to copy cluster files")
    if not nodes:
        nodes = list_cluster_nodes()
        nodes.remove(this_node())
    opts = parallax.Options()
    opts.timeout = 60
    opts.ssh_options += ['ControlPersist=no']
    ok = True
    for host, result in parallax.copy(nodes,
                                      local_path,
                                      local_path, opts).iteritems():
        if isinstance(result, parallax.Error):
            err_buf.error("Failed to push %s to %s: %s" % (local_path, host, result))
            ok = False
        else:
            err_buf.ok(host)
    return ok
Beispiel #7
0
def cluster_copy_file(local_path, nodes=None):
    """
    Copies given file to all other cluster nodes.
    """
    try:
        import parallax
    except ImportError:
        raise ValueError("parallax is required to copy cluster files")
    if not nodes:
        nodes = list_cluster_nodes()
        nodes.remove(this_node())
    opts = parallax.Options()
    opts.timeout = 60
    opts.ssh_options += ['ControlPersist=no']
    ok = True
    for host, result in parallax.copy(nodes, local_path, local_path,
                                      opts).iteritems():
        if isinstance(result, parallax.Error):
            err_buf.error("Failed to push %s to %s: %s" %
                          (local_path, host, result))
            ok = False
        else:
            err_buf.ok(host)
    return ok
Beispiel #8
0
def push_configuration(nodes):
    '''
    Push the local configuration to the list of remote nodes
    '''
    try:
        import parallax
    except ImportError:
        raise ValueError("parallax is required to push")

    local_path = conf()

    opts = parallax.Options()
    opts.timeout = 60
    opts.ssh_options += ['ControlPersist=no']
    ok = True
    for host, result in parallax.copy(nodes,
                                      local_path,
                                      local_path, opts).iteritems():
        if isinstance(result, parallax.Error):
            err_buf.error("Failed to push configuration to %s: %s" % (host, result))
            ok = False
        else:
            err_buf.ok(host)
    return ok
Beispiel #9
0
def _pssh_copy(hosts, src, dst, opts):
    "pssh.copy with debug logging"
    if config.core.debug or options.regression_tests:
        err_buf.debug("pssh.copy(%s, %s, %s)" % (repr(hosts), src, dst))
    return pssh.copy(hosts, src, dst, opts)
Beispiel #10
0
def _pssh_copy(hosts, src, dst, opts):
    "pssh.copy with debug logging"
    if config.core.debug or options.regression_tests:
        err_buf.debug("pssh.copy(%s, %s, %s)" % (repr(hosts), src, dst))
    return pssh.copy(hosts, src, dst, opts)
Beispiel #11
0
 def copy(self):
     results = parallax.copy(self.nodes, self.src, self.dst, self.opts)
     return self.handle(list(results.items()))