Ejemplo n.º 1
0
def run_remote_synctool(nodes):
	if not nodes:
		return
	
	if not synctool_param.RSYNC_CMD:
		stderr('%s: error: rsync_cmd has not been defined in %s' % (os.path.basename(sys.argv[0]), synctool_param.CONF_FILE))
		sys.exit(-1)

	if not synctool_param.SSH_CMD:
		stderr('%s: error: ssh_cmd has not been defined in %s' % (os.path.basename(sys.argv[0]), synctool_param.CONF_FILE))
		sys.exit(-1)

	if not synctool_param.SYNCTOOL_CMD:
		stderr('%s: error: synctool_cmd has not been defined in %s' % (os.path.basename(sys.argv[0]), synctool_param.CONF_FILE))
		sys.exit(-1)

	# prepare rsync command
	if not OPT_SKIP_RSYNC:
		rsync_cmd_arr = shlex.split(synctool_param.RSYNC_CMD)
		rsync_cmd_arr.append('%s/' % synctool_param.MASTERDIR)
	else:
		rsync_cmd_arr = None

	# prepare remote synctool command
	ssh_cmd_arr = shlex.split(synctool_param.SSH_CMD)
	synctool_cmd_arr = shlex.split(synctool_param.SYNCTOOL_CMD)
	synctool_cmd_arr.extend(PASS_ARGS)
	
	# run in parallel
	synctool_lib.run_parallel(master_synctool, worker_synctool,
		(nodes, rsync_cmd_arr, ssh_cmd_arr, synctool_cmd_arr), len(nodes))
Ejemplo n.º 2
0
def run_remote_copy(nodes, files):
    """copy files[] to nodes[]"""

    if not synctool_param.SCP_CMD:
        stderr(
            "%s: error: scp_cmd has not been defined in %s" % (os.path.basename(sys.argv[0]), synctool_param.CONF_FILE)
        )
        sys.exit(-1)

    scp_cmd_arr = shlex.split(synctool_param.SCP_CMD)

    if SCP_OPTIONS:
        scp_cmd_arr.extend(shlex.split(SCP_OPTIONS))

    for node in nodes:
        if node == synctool_param.NODENAME:
            verbose("skipping node %s" % node)
            nodes.remove(node)
            break

    scp_cmd_arr.extend(files)

    files_str = string.join(files)  # this is used only for printing

    synctool_lib.run_parallel(master_scp, worker_scp, (nodes, scp_cmd_arr, files_str), len(nodes))
Ejemplo n.º 3
0
def ping_nodes(nodes):
	'''ping nodes in parallel'''
	'''nodes is a list of interfaces, really'''
	
	if not synctool_param.PING_CMD:
		stderr('%s: error: ping_cmd has not been defined in %s' % (os.path.basename(sys.argv[0]), synctool_param.CONF_FILE))
		sys.exit(-1)
	
	synctool_lib.run_parallel(master_ping, worker_ping, nodes, len(nodes))
Ejemplo n.º 4
0
def run_dsh(remote_cmd_arr):
	'''run remote command to a set of nodes using ssh (param ssh_cmd)'''
	
	nodes = NODESET.interfaces()
	if nodes == None or len(nodes) <= 0:
		print 'no valid nodes specified'
		sys.exit(1)
	
	if not synctool_param.SSH_CMD:
		stderr('%s: error: ssh_cmd has not been defined in %s' % (os.path.basename(sys.argv[0]), synctool_param.CONF_FILE))
		sys.exit(-1)

	ssh_cmd_arr = shlex.split(synctool_param.SSH_CMD)
	
	if SSH_OPTIONS:
		ssh_cmd_arr.extend(shlex.split(SSH_OPTIONS))
	
	synctool_lib.run_parallel(master_ssh, worker_ssh,
		(nodes, ssh_cmd_arr, remote_cmd_arr), len(nodes))
Ejemplo n.º 5
0
def run_remote_pkg(nodes):
	if not nodes:
		return
	
	if not synctool_param.SSH_CMD:
		stderr('%s: error: ssh_cmd has not been defined in %s' % (os.path.basename(sys.argv[0]), synctool_param.CONF_FILE))
		sys.exit(-1)

	if not synctool_param.PKG_CMD:
		stderr('%s: error: pkg_cmd has not been defined in %s' % (os.path.basename(sys.argv[0]), synctool_param.CONF_FILE))
		sys.exit(-1)

	# prepare remote synctool_pkg command
	ssh_cmd_arr = shlex.split(synctool_param.SSH_CMD)
	pkg_cmd_arr = shlex.split(synctool_param.PKG_CMD)
	pkg_cmd_arr.extend(PASS_ARGS)
	
	# run in parallel
	synctool_lib.run_parallel(master_pkg, worker_pkg,
		(nodes, ssh_cmd_arr, pkg_cmd_arr), len(nodes))
Ejemplo n.º 6
0
def run_remote_synctool(nodes):
	if not nodes:
		return
	
	if not synctool_param.RSYNC_CMD:
		stderr('%s: error: rsync_cmd has not been defined in %s' % (os.path.basename(sys.argv[0]), synctool_param.CONF_FILE))
		sys.exit(-1)

	if not synctool_param.SSH_CMD:
		stderr('%s: error: ssh_cmd has not been defined in %s' % (os.path.basename(sys.argv[0]), synctool_param.CONF_FILE))
		sys.exit(-1)

	if not synctool_param.SYNCTOOL_CMD:
		stderr('%s: error: synctool_cmd has not been defined in %s' % (os.path.basename(sys.argv[0]), synctool_param.CONF_FILE))
		sys.exit(-1)

	# prepare rsync command
	if not OPT_SKIP_RSYNC:
		rsync_cmd_arr = shlex.split(synctool_param.RSYNC_CMD)
		if OPT_FILTER_RSYNC and synctool_param.MASTERDIR + "/overlay" not in synctool_param.OVERLAY_DIRS:
			# Include only the overlay directories declared in the conf file
			for rsync_incl_dir in synctool_param.OVERLAY_DIRS:
				if rsync_incl_dir.startswith(synctool_param.MASTERDIR):
					rsync_incl_dir = rsync_incl_dir[len(synctool_param.MASTERDIR):]
				rsync_cmd_arr.append('--include=%s' % (rsync_incl_dir) )
			rsync_cmd_arr.append('--exclude=/overlay/*')
			rsync_cmd_arr.append('--delete-excluded')
		rsync_cmd_arr.append('%s/' % synctool_param.MASTERDIR)
	else:
		rsync_cmd_arr = None

	# prepare remote synctool command
	ssh_cmd_arr = shlex.split(synctool_param.SSH_CMD)
	synctool_cmd_arr = shlex.split(synctool_param.SYNCTOOL_CMD)
	synctool_cmd_arr.extend(PASS_ARGS)
	
	# run in parallel
	synctool_lib.run_parallel(master_synctool, worker_synctool,
		(nodes, rsync_cmd_arr, ssh_cmd_arr, synctool_cmd_arr), len(nodes))