Exemplo n.º 1
0
def main():
	sys.stdout = synctool_unbuffered.Unbuffered(sys.stdout)
	sys.stderr = synctool_unbuffered.Unbuffered(sys.stderr)
	
	get_options()
	
	if OPT_AGGREGATE:
		synctool_aggr.run(MASTER_OPTS)
		sys.exit(0)
	
	synctool_config.add_myhostname()
	
	# ooh ... testing for DRY_RUN doesn't work here
#	if '-f' in PASS_ARGS or '--fix' in PASS_ARGS:
#		synctool_lib.openlog()
	
	nodes = NODESET.interfaces()
	if nodes == None or len(nodes) <= 0:
		print 'no valid nodes specified'
		sys.exit(1)
	
	local_interface = synctool_config.get_node_interface(synctool_param.NODENAME)
	
	for node in nodes:
		#
		#	is this node the localhost? then run locally
		#
		if node == local_interface:
			run_local_pkg()
			nodes.remove(node)
			break
	
	run_remote_pkg(nodes)
Exemplo n.º 2
0
def main():
	sys.stdout = synctool_unbuffered.Unbuffered(sys.stdout)
	sys.stderr = synctool_unbuffered.Unbuffered(sys.stderr)

	(upload_filename, upload_suffix) = get_options()

	if OPT_CHECK_UPDATE:
		import synctool_update
		sys.exit(synctool_update.check())

	if OPT_DOWNLOAD:
		import synctool_update
		sys.exit(synctool_update.download())

	if OPT_AGGREGATE:
		synctool_aggr.run(MASTER_OPTS)
		sys.exit(0)

	synctool_config.add_myhostname()

	# ooh ... testing for DRY_RUN doesn't work here
	if '-f' in PASS_ARGS or '--fix' in PASS_ARGS:
		synctool_lib.openlog()

	nodes = NODESET.interfaces()
	if nodes == None or len(nodes) <= 0:
		print 'no valid nodes specified'
		sys.exit(1)

	if upload_filename:			# upload a file
		if len(nodes) != 1:
			print "The option --upload can only be run on just one node"
			print "Please use --node=nodename to specify the node to upload from"
			sys.exit(1)
		
		upload(nodes[0], upload_filename, upload_suffix)

	else:						# do regular synctool run
		local_interface = synctool_config.get_node_interface(synctool_param.NODENAME)

		for node in nodes:
			#
			#	is this node the localhost? then run locally
			#
			if node == local_interface:
				run_local_synctool()
				nodes.remove(node)
				break

		run_remote_synctool(nodes)

	synctool_lib.closelog()
Exemplo n.º 3
0
def main():
	sys.stdout = synctool_unbuffered.Unbuffered(sys.stdout)
	sys.stderr = synctool_unbuffered.Unbuffered(sys.stderr)
	
	cmd_args = get_options()
	
	if OPT_AGGREGATE:
		synctool_aggr.run(MASTER_OPTS)
		sys.exit(0)
	
	synctool_config.add_myhostname()
	
	run_dsh(cmd_args)
Exemplo n.º 4
0
def main():
    sys.stdout = synctool_unbuffered.Unbuffered(sys.stdout)
    sys.stderr = synctool_unbuffered.Unbuffered(sys.stderr)

    files = get_options()

    if OPT_AGGREGATE:
        synctool_aggr.run(MASTER_OPTS)
        sys.exit(0)

    synctool_config.add_myhostname()

    nodes = NODESET.interfaces()
    if nodes == None or len(nodes) <= 0:
        print "no valid nodes specified"
        sys.exit(1)

    run_remote_copy(nodes, files)
Exemplo n.º 5
0
def main():
	sys.stdout = synctool_unbuffered.Unbuffered(sys.stdout)
	sys.stderr = synctool_unbuffered.Unbuffered(sys.stderr)
	
	cmd_args = get_options()
	
	if OPT_AGGREGATE:
		synctool_aggr.run(MASTER_OPTS)
		sys.exit(0)
	
	synctool_config.add_myhostname()
	
	nodes = NODESET.interfaces()
	if nodes == None or len(nodes) <= 0:
		print 'no valid nodes specified'
		sys.exit(1)
	
	ping_nodes(nodes)
Exemplo n.º 6
0
def main():
	action = get_options()
	
	synctool_config.add_myhostname()
	
	if synctool_param.NODENAME == None:
		stderr('unable to determine my nodename, please check %s' % synctool_param.CONF_FILE)
		sys.exit(1)
	
	if synctool_param.NODENAME in synctool_param.IGNORE_GROUPS:
		stderr('%s: node %s is disabled in the config file' % (synctool_param.CONF_FILE, synctool_param.NODENAME))
		sys.exit(1)
	
	synctool_config.remove_ignored_groups()
	
	synctool_param.MY_GROUPS = synctool_config.get_my_groups()
	synctool_param.ALL_GROUPS = synctool_config.make_all_groups()
	
	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('# NODENAME=%s' % synctool_param.NODENAME)
		unix_out('# HOSTNAME=%s' % synctool_param.HOSTNAME)
		unix_out('# MASTERDIR=%s' % synctool_param.MASTERDIR)
		unix_out('# SYMLINK_MODE=0%o' % synctool_param.SYMLINK_MODE)
		unix_out('#')
		
		if not synctool_lib.DRY_RUN:
			unix_out('# NOTE: --fix specified, applying updates')
			unix_out('#')
		
		unix_out('')
	else:
		if not synctool_lib.QUIET:
			verbose('my nodename: %s' % synctool_param.NODENAME)
			verbose('my hostname: %s' % synctool_param.HOSTNAME)
			verbose('masterdir: %s' % synctool_param.MASTERDIR)
			verbose('symlink_mode: 0%o' % synctool_param.SYMLINK_MODE)
			
			if synctool_param.LOGFILE != None and not synctool_lib.DRY_RUN:
				verbose('logfile: %s' % synctool_param.LOGFILE)
			
			verbose('')
			
			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')
			
			verbose('')
	
	synctool_lib.openlog()
	
	os.putenv('SYNCTOOL_NODENAME', synctool_param.NODENAME)
	os.putenv('SYNCTOOL_MASTERDIR', synctool_param.MASTERDIR)
	
	if action == ACTION_DIFF:
		for file in SINGLE_FILES:
			diff_files(file)
	
	elif action == ACTION_RUN_TASKS:
		if SINGLE_FILES:
			for single_file in SINGLE_FILES:
				single_task(single_file)
		else:
			run_tasks()
	
	elif action == ACTION_REFERENCE:
		for file in SINGLE_FILES:
			reference(file)
	
	elif SINGLE_FILES:
		for single_file in SINGLE_FILES:
			(changed, src) = single_files(single_file)
			if changed:
				run_post(src, single_file)
		
		run_post_on_directories()
	
	else:
		overlay_files()
		delete_files()
		run_post_on_directories()
		always_run()
	
	unix_out('# EOB')
	
	synctool_lib.closelog()