コード例 #1
0
ファイル: configure.py プロジェクト: aspiers/crmsh
def make_bindnetaddr():
    host = crm_script.host()
    hostinfo = crm_script.output(2)[host]
    ba = crm_script.param('bindnetaddr')
    if ba:
        return ba

    # if not, try to figure it out based
    # on preferred interface
    iface = crm_script.param('iface')
    if isinstance(iface, dict):
        iface = iface[host]
    interfaces = hostinfo['net']['interfaces']
    if not iface:
        for info in interfaces:
            if info.get('Destination') == '0.0.0.0':
                iface = info.get('Iface')
                break
    try:
        for info in interfaces:
            if info.get('Iface') != iface:
                continue
            dst = info.get('Destination')
            if dst != '0.0.0.0':
                return info.get('Destination')
    except:
        pass
    crm_script.fail_exit("Could not discover appropriate bindnetaddr")
コード例 #2
0
def make_bindnetaddr():
    host = crm_script.host()
    hostinfo = crm_script.output(1)[host]
    ba = crm_script.param('bindnetaddr')
    if ba:
        return ba

    # if not, try to figure it out based
    # on preferred interface
    iface = crm_script.param('iface')
    if isinstance(iface, dict):
        iface = iface[host]
    interfaces = hostinfo['net']['interfaces']
    if not iface:
        for info in interfaces:
            if info.get('Destination') == '0.0.0.0':
                iface = info.get('Iface')
                break
    try:
        for info in interfaces:
            if info.get('Iface') != iface:
                continue
            dst = info.get('Destination')
            if dst != '0.0.0.0':
                return info.get('Destination')
    except:
        pass
    crm_script.fail_exit("Could not discover appropriate bindnetaddr")
コード例 #3
0
#!/usr/bin/env python
import crm_script
import os
import stat

host = crm_script.host()
others = crm_script.output(1).keys()
others.remove(host)

COROSYNC_AUTH = '/etc/corosync/authkey'
COROSYNC_CONF = '/etc/corosync/corosync.conf'


def make_opts():
    from psshlib import api as pssh
    opts = pssh.Options()
    opts.timeout = 60
    opts.recursive = True
    opts.user = '******'
    opts.ssh_options += [
        'PasswordAuthentication=no', 'StrictHostKeyChecking=no',
        'ControlPersist=no'
    ]
    return opts


def check_results(pssh, results):
    failures = []
    for host, result in results.items():
        if isinstance(result, pssh.Error):
            failures.add("%s: %s" % (host, str(result)))
コード例 #4
0
ファイル: authkey.py プロジェクト: RedFlames/crmsh
#!/usr/bin/env python
import crm_script
import os
import stat

host = crm_script.host()
others = crm_script.output(2).keys()
others.remove(host)

COROSYNC_AUTH = '/etc/corosync/authkey'
COROSYNC_CONF = '/etc/corosync/corosync.conf'


def make_opts():
    import parallax
    opts = parallax.Options()
    opts.timeout = 60
    opts.recursive = True
    opts.user = '******'
    opts.ssh_options += ['PasswordAuthentication=no',
                         'StrictHostKeyChecking=no',
                         'ControlPersist=no']
    return opts


def check_results(parallax, results):
    failures = []
    for host, result in results.items():
        if isinstance(result, parallax.Error):
            failures.add("%s: %s" % (host, str(result)))
    if failures: