Ejemplo n.º 1
0
// takes in list of unique hosts
func scpTestFiles(hostnames []string) map[string]bool {
	var wg sync.WaitGroup
	failed := make(map[string]bool)
	var mu sync.Mutex
	for _, host := range hostnames {
		wg.Add(1)
		log.Println("scp test files:", host, hostnames)

		go func(host string) {
			defer wg.Done()
			err := cliutils.TimeoutRun(10*time.Second,
				func() error { return cliutils.Scp(uname, host, "latency_test", "latency_test") })
			if err != nil {
				log.Println("Failed:", host, err)
				mu.Lock()
				failed[host] = true
				mu.Unlock()
				return
			}

			err = cliutils.TimeoutRun(10*time.Second,
				func() error { return cliutils.Scp(uname, host, hostfile, "hosts.txt") })
			if err != nil {
				log.Println("Failed:", host, err)
				mu.Lock()
				failed[host] = true
				mu.Unlock()
				return
			}
		}(host)
	}
	wg.Wait()
	return failed
}
Ejemplo n.º 2
0
func scpServerFiles(hostnames []string) {
	var wg sync.WaitGroup
	for _, host := range hostnames {
		wg.Add(1)
		go func(host string) {
			defer wg.Done()
			if err := cliutils.Scp(uname, host, "cfg.json", "cfg.json"); err != nil {
				log.Fatal(host, err)
			}
			if err := cliutils.Scp(uname, host, "exec", "cocoexec"); err != nil {
				log.Println(host, err)
			}
		}(host)
	}
	wg.Wait()
}
Ejemplo n.º 3
0
func setupLogger() {
	h, _, err := net.SplitHostPort(logger)
	if err != nil {
		log.Info(err)
		h = logger
	}
	// build the logserver for the logger's environment
	err = cliutils.Build("../logserver", "386", "linux")
	if err != nil {
		log.Fatal("failed to build logserver:", err)
	}
	// move the build to the logserver directory
	err = os.Rename("logserver", "../logserver/logserver")
	if err != nil {
		log.Fatal("failed to rename logserver:", err)
	}
	// scp the logserver to the environment it will run on
	err = cliutils.Scp(uname, h, "../logserver", "~/")
	if err != nil {
		log.Fatal("failed to scp logserver:", err)
	}
	// startup the logserver
	go func() {
		cliutils.SshRunStdout(uname, h, "cd logserver; ./logserver -addr="+logger)
		if err != nil {
			log.Fatal("failed to run logserver:", err)
		}
	}()
}
Ejemplo n.º 4
0
func scpClientFiles(clients []string) {
	var wg sync.WaitGroup
	log.Println("sending client files:", clients)
	for _, c := range clients {
		wg.Add(1)
		go func(client string) {
			defer wg.Done()
			if err := cliutils.Scp(uname, client, "timeclient", "timeclient"); err != nil {
				log.Println(client, err)
			}
		}(c)
	}
	wg.Wait()
}