示例#1
0
def main():
    '''run the program'''

    param.init()

    sys.stdout = synctool.unbuffered.Unbuffered(sys.stdout)
    sys.stderr = synctool.unbuffered.Unbuffered(sys.stderr)

    try:
        files = get_options()
    except synctool.range.RangeSyntaxError as err:
        error(str(err))
        sys.exit(1)

    if OPT_AGGREGATE:
        if not synctool.aggr.run(MASTER_OPTS):
            sys.exit(-1)

        sys.exit(0)

    config.init_mynodename()

    address_list = NODESET.addresses()
    if not address_list:
        error('no valid nodes specified')
        sys.exit(1)

    run_remote_copy(address_list, files)
示例#2
0
def main():
    '''run the program'''

    param.init()

    sys.stdout = synctool.unbuffered.Unbuffered(sys.stdout)
    sys.stderr = synctool.unbuffered.Unbuffered(sys.stderr)

    try:
        get_options()
    except synctool.range.RangeSyntaxError as err:
        error(str(err))
        sys.exit(1)

    if OPT_AGGREGATE:
        if not synctool.aggr.run(MASTER_OPTS):
            sys.exit(-1)

        sys.exit(0)

    config.init_mynodename()

    address_list = NODESET.addresses()
    if not address_list:
        print 'no valid nodes specified'
        sys.exit(1)

    ping_nodes(address_list)
示例#3
0
def main():
    # type: () -> None
    '''run the program'''

    param.init()

    sys.stdout = synctool.unbuffered.Unbuffered(sys.stdout)  # type: ignore
    sys.stderr = synctool.unbuffered.Unbuffered(sys.stderr)  # type: ignore

    try:
        files = get_options()
    except synctool.range.RangeSyntaxError as err:
        error(str(err))
        sys.exit(1)

    if OPT_AGGREGATE:
        if not synctool.aggr.run(MASTER_OPTS):
            sys.exit(-1)

        sys.exit(0)

    config.init_mynodename()

    address_list = NODESET.addresses()
    if not address_list:
        error('no valid nodes specified')
        sys.exit(1)

    run_remote_copy(address_list, files)
示例#4
0
def main():
    '''run the program'''

    param.init()

    sys.stdout = synctool.unbuffered.Unbuffered(sys.stdout)
    sys.stderr = synctool.unbuffered.Unbuffered(sys.stderr)

    try:
        cmd_args = get_options()
    except synctool.range.RangeSyntaxError as err:
        error(str(err))
        sys.exit(1)

    if OPT_AGGREGATE:
        if not synctool.aggr.run(MASTER_OPTS):
            sys.exit(-1)

        sys.exit(0)

    config.init_mynodename()

    address_list = NODESET.addresses()
    if not address_list:
        error('no valid nodes specified')
        sys.exit(1)

    if OPT_MULTIPLEX:
        start_multiplex(address_list)
    elif CTL_CMD != None:
        control_multiplex(address_list, CTL_CMD)
    else:
        run_dsh(address_list, cmd_args)
示例#5
0
def main():
    '''run the program'''

    param.init()

    sys.stdout = synctool.unbuffered.Unbuffered(sys.stdout)
    sys.stderr = synctool.unbuffered.Unbuffered(sys.stderr)

    try:
        cmd_args = get_options()
    except synctool.range.RangeSyntaxError as err:
        error(str(err))
        sys.exit(1)

    if OPT_AGGREGATE:
        if not synctool.aggr.run(MASTER_OPTS):
            sys.exit(-1)

        sys.exit(0)

    config.init_mynodename()

    address_list = NODESET.addresses()
    if not address_list:
        error('no valid nodes specified')
        sys.exit(1)

    if OPT_MULTIPLEX:
        start_multiplex(address_list)
    elif CTL_CMD != None:
        control_multiplex(address_list, CTL_CMD)
    else:
        run_dsh(address_list, cmd_args)
示例#6
0
def main():
    # type: () -> None
    '''run the program'''

    param.init()

    sys.stdout = synctool.unbuffered.Unbuffered(sys.stdout) # type: ignore
    sys.stderr = synctool.unbuffered.Unbuffered(sys.stderr) # type: ignore

    try:
        get_options()
    except synctool.range.RangeSyntaxError as err:
        error(str(err))
        sys.exit(1)

    if OPT_AGGREGATE:
        if not synctool.aggr.run(MASTER_OPTS):
            sys.exit(-1)

        sys.exit(0)

    config.init_mynodename()

    address_list = NODESET.addresses()
    if not address_list:
        print 'no valid nodes specified'
        sys.exit(1)

    ping_nodes(address_list)
示例#7
0
def main():
    # type: () -> None
    '''run the program'''

    param.init()

    sys.stdout = synctool.unbuffered.Unbuffered(sys.stdout) # type: ignore
    sys.stderr = synctool.unbuffered.Unbuffered(sys.stderr) # type: ignore

    try:
        get_options()
    except synctool.range.RangeSyntaxError as err:
        error(str(err))
        sys.exit(1)

    if OPT_AGGREGATE:
        if not synctool.aggr.run(MASTER_OPTS):
            sys.exit(-1)

        sys.exit(0)

    config.init_mynodename()

    if param.MASTER != param.HOSTNAME:
        verbose('master %s != hostname %s' % (param.MASTER,
                                              param.HOSTNAME))
        error('not running on the master node')
        sys.exit(-1)

    synctool.lib.openlog()

    address_list = NODESET.addresses()
    if not address_list:
        print 'no valid nodes specified'
        sys.exit(1)

    run_remote_pkg(address_list)

    synctool.lib.closelog()
示例#8
0
def main():
    '''run the program'''

    param.init()

    sys.stdout = synctool.unbuffered.Unbuffered(sys.stdout)
    sys.stderr = synctool.unbuffered.Unbuffered(sys.stderr)

    try:
        get_options()
    except synctool.range.RangeSyntaxError as err:
        error(str(err))
        sys.exit(1)

    if OPT_AGGREGATE:
        if not synctool.aggr.run(MASTER_OPTS):
            sys.exit(-1)

        sys.exit(0)

    config.init_mynodename()

    if param.MASTER != param.HOSTNAME:
        verbose('master %s != hostname %s' % (param.MASTER,
                                              param.HOSTNAME))
        error('not running on the master node')
        sys.exit(-1)

    synctool.lib.openlog()

    address_list = NODESET.addresses()
    if not address_list:
        print 'no valid nodes specified'
        sys.exit(1)

    run_remote_pkg(address_list)

    synctool.lib.closelog()
示例#9
0
文件: client.py 项目: zenny/synctool
def main():
    # type: () -> None
    '''run the program'''

    param.init()

    action = get_options()

    config.init_mynodename()

    if not param.NODENAME:
        error('unable to determine my nodename (hostname: %s)' %
              param.HOSTNAME)
        stderr('please check %s' % param.CONF_FILE)
        sys.exit(-1)

    if param.NODENAME not in param.NODES:
        error("unknown node '%s'" % param.NODENAME)
        stderr('please check %s' % param.CONF_FILE)
        sys.exit(-1)

    if param.NODENAME in param.IGNORE_GROUPS:
        # this is only a warning ...
        # you can still run synctool-pkg on the client by hand
        warning('node %s is disabled in %s' %
                (param.NODENAME, param.CONF_FILE))

    if synctool.lib.UNIX_CMD:
        t = time.localtime(time.time())

        unix_out('#')
        unix_out('# script generated by synctool on '
                 '%04d/%02d/%02d %02d:%02d:%02d' %
                 (t[0], t[1], t[2], t[3], t[4], t[5]))
        unix_out('#')
        unix_out('# my hostname: %s' % param.HOSTNAME)
        unix_out('# SYNCTOOL_NODE=%s' % param.NODENAME)
        unix_out('# SYNCTOOL_ROOT=%s' % param.ROOTDIR)
        unix_out('#')

        if not synctool.lib.DRY_RUN:
            unix_out('# NOTE: --fix specified, applying updates')
            unix_out('#')

        unix_out('')
    else:
        if not synctool.lib.MASTERLOG:
            # only print this when running stand-alone
            if not synctool.lib.QUIET:
                if synctool.lib.DRY_RUN:
                    stdout('DRY RUN, not doing any updates')
                    terse(synctool.lib.TERSE_DRYRUN, 'not doing any updates')
                else:
                    stdout('--fix specified, applying changes')
                    terse(synctool.lib.TERSE_FIXING, ' applying changes')

            else:
                if synctool.lib.DRY_RUN:
                    verbose('DRY RUN, not doing any updates')
                else:
                    verbose('--fix specified, applying changes')

        verbose('my nodename: %s' % param.NODENAME)
        verbose('my hostname: %s' % param.HOSTNAME)
        verbose('rootdir: %s' % param.ROOTDIR)

    os.environ['SYNCTOOL_NODE'] = param.NODENAME
    os.environ['SYNCTOOL_ROOT'] = param.ROOTDIR

    unix_out('umask 077')
    unix_out('')
    os.umask(077)

    if action == ACTION_DIFF:
        diff_files()

    elif action == ACTION_REFERENCE:
        reference_files()

    elif action == ACTION_ERASE_SAVED:
        if SINGLE_FILES:
            single_erase_saved()
        else:
            erase_saved()

    elif SINGLE_FILES:
        single_files()

    else:
        purge_files()
        overlay_files()
        delete_files()

    unix_out('# EOB')
示例#10
0
def main():
    # type: () -> None
    '''do your thing'''

    param.init()

    get_options()

    if ACTION == ACTION_VERSION:
        print param.VERSION
        sys.exit(0)

    if ACTION == ACTION_FQDN:
        print socket.getfqdn()
        sys.exit(0)

    config.read_config()
#    synctool.nodeset.make_default_nodeset()

    if ACTION == ACTION_LIST_NODES:
        list_all_nodes()

    elif ACTION == ACTION_LIST_GROUPS:
        list_all_groups()

    elif ACTION == ACTION_NODES:
        if not ARG_NODENAMES:
            error("option '--node' requires an argument; the node name")
            sys.exit(1)

        list_nodes(ARG_NODENAMES)

    elif ACTION == ACTION_GROUPS:
        if not ARG_GROUPS:
            error("option '--node-group' requires an argument; "
                  "the node group name")
            sys.exit(1)

        list_nodegroups(ARG_GROUPS)

    elif ACTION == ACTION_CMDS:
        list_commands(ARG_CMDS)

    elif ACTION == ACTION_PKGMGR:
        print param.PACKAGE_MANAGER

    elif ACTION == ACTION_NUMPROC:
        print param.NUM_PROC

    elif ACTION == ACTION_LIST_DIRS:
        list_dirs()

    elif ACTION == ACTION_PREFIX:
        print param.ROOTDIR

    elif ACTION == ACTION_NODENAME:
        config.init_mynodename()

        if not param.NODENAME:
            error('unable to determine my nodename (%s)' %
                  param.HOSTNAME)
            stderr('please check %s' % param.CONF_FILE)
            sys.exit(1)

        print param.NODENAME

    elif ACTION == ACTION_MASTER:
        print param.MASTER

    elif ACTION == ACTION_SLAVE:
        if not param.SLAVES:
            print '(none)'
        else:
            for node in param.SLAVES:
                print node,
            print

    elif ACTION == ACTION_EXPAND:
        if not ARG_EXPAND:
            print 'none'
        else:
            expand(ARG_EXPAND)

    else:
        raise RuntimeError('bug: unknown ACTION code %d' % ACTION)
示例#11
0
def main():
    '''do your thing'''

    param.init()

    get_options()

    if ACTION == ACTION_VERSION:
        print param.VERSION
        sys.exit(0)

    if ACTION == ACTION_FQDN:
        print socket.getfqdn()
        sys.exit(0)

    config.read_config()
    #    synctool.nodeset.make_default_nodeset()

    if ACTION == ACTION_LIST_NODES:
        list_all_nodes()

    elif ACTION == ACTION_LIST_GROUPS:
        list_all_groups()

    elif ACTION == ACTION_NODES:
        if not ARG_NODENAMES:
            error("option '--node' requires an argument; the node name")
            sys.exit(1)

        list_nodes(ARG_NODENAMES)

    elif ACTION == ACTION_GROUPS:
        if not ARG_GROUPS:
            error("option '--node-group' requires an argument; "
                  "the node group name")
            sys.exit(1)

        list_nodegroups(ARG_GROUPS)

    elif ACTION == ACTION_CMDS:
        list_commands(ARG_CMDS)

    elif ACTION == ACTION_PKGMGR:
        print param.PACKAGE_MANAGER

    elif ACTION == ACTION_NUMPROC:
        print param.NUM_PROC

    elif ACTION == ACTION_LIST_DIRS:
        list_dirs()

    elif ACTION == ACTION_PREFIX:
        print param.ROOTDIR

    elif ACTION == ACTION_NODENAME:
        config.init_mynodename()

        if not param.NODENAME:
            error('unable to determine my nodename (%s)' % param.HOSTNAME)
            stderr('please check %s' % param.CONF_FILE)
            sys.exit(1)

        print param.NODENAME

    elif ACTION == ACTION_MASTER:
        print param.MASTER

    elif ACTION == ACTION_SLAVE:
        if not len(param.SLAVES):
            print '(none)'
        else:
            for node in param.SLAVES:
                print node,
            print

    elif ACTION == ACTION_EXPAND:
        if not ARG_EXPAND:
            print 'none'
        else:
            expand(ARG_EXPAND)

    else:
        raise RuntimeError('bug: unknown ACTION code %d' % ACTION)
示例#12
0
def main():
    # type: () -> None
    '''run the program'''

    param.init()

    sys.stdout = synctool.unbuffered.Unbuffered(sys.stdout) # type: ignore
    sys.stderr = synctool.unbuffered.Unbuffered(sys.stderr) # type: ignore

    try:
        get_options()
    except synctool.range.RangeSyntaxError as err:
        error(str(err))
        sys.exit(1)

    if OPT_CHECK_UPDATE:
        if not synctool.update.check():
            # no newer version available
            sys.exit(0)

        sys.exit(1)

    if OPT_DOWNLOAD:
        if not synctool.update.download():
            # download error
            sys.exit(-1)

        sys.exit(0)

    if OPT_AGGREGATE:
        if not synctool.aggr.run(MASTER_OPTS):
            sys.exit(-1)

        sys.exit(0)

    config.init_mynodename()

    if param.MASTER != param.HOSTNAME:
        verbose('master %s != hostname %s' % (param.MASTER, param.HOSTNAME))
        error('not running on the master node')
        sys.exit(-1)

    if not _check_valid_overlaydirs():
        # error message already printed
        sys.exit(-1)

    synctool.lib.openlog()

    address_list = NODESET.addresses()
    if not address_list:
        print 'no valid nodes specified'
        sys.exit(1)

    if UPLOAD_FILE.filename:
        # upload a file
        if len(address_list) != 1:
            error('option --upload can only be run on just one node')
            stderr('Please use --node=nodename to specify the node '
                   'to upload from')
            sys.exit(1)

        UPLOAD_FILE.address = address_list[0]
        synctool.upload.upload(UPLOAD_FILE)

    else:
        # do regular synctool run
        # first print message about DRY RUN
        if not synctool.lib.QUIET:
            if synctool.lib.DRY_RUN:
                stdout('DRY RUN, not doing any updates')
                terse(synctool.lib.TERSE_DRYRUN, 'not doing any updates')
            else:
                stdout('--fix specified, applying changes')
                terse(synctool.lib.TERSE_FIXING, ' applying changes')
        else:
            if synctool.lib.DRY_RUN:
                verbose('DRY RUN, not doing any updates')
            else:
                verbose('--fix specified, applying changes')

        make_tempdir()
        run_remote_synctool(address_list)

    synctool.lib.closelog()
示例#13
0
def main():
    '''run the program'''

    param.init()

    sys.stdout = synctool.unbuffered.Unbuffered(sys.stdout)
    sys.stderr = synctool.unbuffered.Unbuffered(sys.stderr)

    try:
        get_options()
    except synctool.range.RangeSyntaxError as err:
        error(str(err))
        sys.exit(1)

    if OPT_CHECK_UPDATE:
        if not synctool.update.check():
            # no newer version available
            sys.exit(0)

        sys.exit(1)

    if OPT_DOWNLOAD:
        if not synctool.update.download():
            # download error
            sys.exit(-1)

        sys.exit(0)

    if OPT_AGGREGATE:
        if not synctool.aggr.run(MASTER_OPTS):
            sys.exit(-1)

        sys.exit(0)

    config.init_mynodename()

    if param.MASTER != param.HOSTNAME:
        verbose('master %s != hostname %s' % (param.MASTER, param.HOSTNAME))
        error('not running on the master node')
        sys.exit(-1)

    if not _check_valid_overlaydirs():
        # error message already printed
        sys.exit(-1)

    synctool.lib.openlog()

    address_list = NODESET.addresses()
    if not address_list:
        print 'no valid nodes specified'
        sys.exit(1)

    if UPLOAD_FILE.filename:
        # upload a file
        if len(address_list) != 1:
            error('option --upload can only be run on just one node')
            stderr('Please use --node=nodename to specify the node '
                   'to upload from')
            sys.exit(1)

        UPLOAD_FILE.address = address_list[0]
        synctool.upload.upload(UPLOAD_FILE)

    else:
        # do regular synctool run
        # first print message about DRY RUN
        if not synctool.lib.QUIET:
            if synctool.lib.DRY_RUN:
                stdout('DRY RUN, not doing any updates')
                terse(synctool.lib.TERSE_DRYRUN, 'not doing any updates')
            else:
                stdout('--fix specified, applying changes')
                terse(synctool.lib.TERSE_FIXING, ' applying changes')
        else:
            if synctool.lib.DRY_RUN:
                verbose('DRY RUN, not doing any updates')
            else:
                verbose('--fix specified, applying changes')

        make_tempdir()
        run_remote_synctool(address_list)

    synctool.lib.closelog()