Exemplo n.º 1
0
def run_copy():
    try:
        from psshlib import api as pssh
    except ImportError:
        crm_script.exit_fail("Command node needs pssh installed")
    opts = make_opts()
    has_auth = os.path.isfile(COROSYNC_AUTH)
    if has_auth:
        results = pssh.copy(add_nodes, COROSYNC_AUTH, COROSYNC_AUTH, opts)
        check_results(pssh, results)
        results = pssh.call(
            add_nodes,
            "chown root:root %s;chmod 400 %s" % (COROSYNC_AUTH, COROSYNC_AUTH),
            opts)
        check_results(pssh, 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 = pssh.copy(add_nodes, COROSYNC_CONF, COROSYNC_CONF, opts)
    check_results(pssh, 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)
Exemplo n.º 2
0
def run_copy():
    try:
        from psshlib import api as pssh
    except ImportError:
        crm_script.exit_fail("Command node needs pssh installed")
    opts = make_opts()
    has_auth = os.path.isfile(COROSYNC_AUTH)
    if has_auth:
        results = pssh.copy(add_nodes, COROSYNC_AUTH, COROSYNC_AUTH, opts)
        check_results(pssh, results)
        results = pssh.call(add_nodes,
                            "chown root:root %s;chmod 400 %s" % (COROSYNC_AUTH, COROSYNC_AUTH),
                            opts)
        check_results(pssh, 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 = pssh.copy(add_nodes, COROSYNC_CONF, COROSYNC_CONF, opts)
    check_results(pssh, 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)
Exemplo n.º 3
0
def push_configuration(nodes):
    '''
    Push the local configuration to the list of remote nodes
    '''
    try:
        from psshlib import api 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
Exemplo n.º 4
0
def push_configuration(nodes):
    '''
    Push the local configuration to the list of remote nodes
    '''
    try:
        from psshlib import api 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
Exemplo n.º 5
0
def run_copy():
    try:
        from psshlib import api as pssh
    except ImportError:
        crm_script.exit_fail("Command node needs pssh 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)
Exemplo n.º 6
0
def run_copy():
    try:
        from psshlib import api as pssh
    except ImportError:
        crm_script.exit_fail("Command node needs pssh 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)
Exemplo n.º 7
0
    def testCopyFile(self):
        opts = pssh.Options()
        opts.default_user = g_user
        opts.localdir = self.tmpDir
        by_host = pssh.copy(g_hosts, "/etc/hosts", "/tmp/pssh.test", opts)
        for host, result in by_host.iteritems():
            rc, _, _ = result
            self.assertEqual(rc, 0)

        by_host = pssh.slurp(g_hosts, "/tmp/pssh.test", "pssh.test", opts)
        for host, result in by_host.iteritems():
            rc, _, _, path = result
            self.assertEqual(rc, 0)
            self.assert_(path.endswith('%s/pssh.test' % (host)))
Exemplo n.º 8
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)
Exemplo n.º 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)