| 420 | } |
| 421 | |
| 422 | func (a shellActions) Run(command string, args ...string) (string, string) { |
| 423 | var cmd *exec.Cmd |
| 424 | if a.fm.Hostname().Host == "localhost" { |
| 425 | // Just run locally. |
| 426 | cmd = exec.Command(command, args...) |
| 427 | } else { |
| 428 | // We must SSH to the remote machine and run the command. |
| 429 | cmd = a.wrapSSH(command, args...) |
| 430 | } |
| 431 | var stdout bytes.Buffer |
| 432 | var stderr bytes.Buffer |
| 433 | cmd.Stdout = &stdout |
| 434 | cmd.Stderr = &stderr |
| 435 | klog.Infof("About to run - %v", cmd.Args) |
| 436 | err := cmd.Run() |
| 437 | if err != nil { |
| 438 | a.fm.T().Fatalf("Failed to run %q %v in %q with error: %q. Stdout: %q, Stderr: %s", command, args, a.fm.Hostname().Host, err, stdout.String(), stderr.String()) |
| 439 | return "", "" |
| 440 | } |
| 441 | return stdout.String(), stderr.String() |
| 442 | } |
| 443 | |
| 444 | func (a shellActions) RunStress(command string, args ...string) (string, string) { |
| 445 | var cmd *exec.Cmd |