-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from DiscoRiver/add-python-script
Implement a script interface
- Loading branch information
Showing
19 changed files
with
498 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/discoriver/massh" | ||
"golang.org/x/crypto/ssh" | ||
"time" | ||
) | ||
|
||
func main() { | ||
j := &massh.Job{ | ||
Command: "echo \"Hello, World\"", | ||
} | ||
|
||
sshc := &ssh.ClientConfig{ | ||
// Fake credentials | ||
User: "u01", | ||
Auth: []ssh.AuthMethod{ssh.Password("password")}, | ||
HostKeyCallback: ssh.InsecureIgnoreHostKey(), | ||
Timeout: time.Duration(2) * time.Second, | ||
} | ||
|
||
cfg := massh.NewConfig() | ||
cfg.SSHConfig = sshc | ||
cfg.Job = j | ||
cfg.WorkerPool = 10 | ||
cfg.SetHosts([]string{"192.168.1.118", "192.168.1.123"}) | ||
|
||
res, err := cfg.Run() | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
for i := range res { | ||
if res[i].Error != nil { | ||
fmt.Printf("%s: %s\n", res[i].Host, res[i].Error) | ||
} else { | ||
fmt.Printf("%s: %s", res[i].Host, res[i].Output) | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/discoriver/massh" | ||
"golang.org/x/crypto/ssh" | ||
"time" | ||
) | ||
|
||
func main() { | ||
j := &massh.Job{ | ||
Command: "echo \"Hello, World\"", | ||
} | ||
|
||
sshc := &ssh.ClientConfig{ | ||
// Fake credentials | ||
User: "u01", | ||
Auth: []ssh.AuthMethod{ssh.Password("password")}, | ||
HostKeyCallback: ssh.InsecureIgnoreHostKey(), | ||
Timeout: time.Duration(2) * time.Second, | ||
} | ||
|
||
cfg := massh.NewConfig() | ||
cfg.SSHConfig = sshc | ||
cfg.Job = j | ||
cfg.WorkerPool = 10 | ||
cfg.SetHosts([]string{"192.168.1.118", "192.168.1.123"}) | ||
|
||
err := cfg.Job.SetScript("script.py", "") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
res, err := cfg.Run() | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
for i := range res { | ||
if res[i].Error != nil { | ||
fmt.Printf("%s: %s\n", res[i].Host, res[i].Error) | ||
} else { | ||
fmt.Printf("%s: %s", res[i].Host, res[i].Output) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env python3 | ||
import sys | ||
sys.stdout.write("Hello world, from python script." + '\n') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/discoriver/massh" | ||
"golang.org/x/crypto/ssh" | ||
"time" | ||
) | ||
|
||
func main() { | ||
j := &massh.Job{ | ||
Command: "echo \"Hello, World\"", | ||
} | ||
|
||
sshc := &ssh.ClientConfig{ | ||
// Fake credentials | ||
User: "u01", | ||
Auth: []ssh.AuthMethod{ssh.Password("password")}, | ||
HostKeyCallback: ssh.InsecureIgnoreHostKey(), | ||
Timeout: time.Duration(2) * time.Second, | ||
} | ||
|
||
cfg := massh.NewConfig() | ||
cfg.SSHConfig = sshc | ||
cfg.Job = j | ||
cfg.WorkerPool = 10 | ||
cfg.SetHosts([]string{"192.168.1.118", "192.168.1.123"}) | ||
|
||
err := cfg.Job.SetScript("script.sh", "") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
res, err := cfg.Run() | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
for i := range res { | ||
if res[i].Error != nil { | ||
fmt.Printf("%s: %s\n", res[i].Host, res[i].Error) | ||
} else { | ||
fmt.Printf("%s: %s", res[i].Host, res[i].Output) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
echo "Hello World, from shell script" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.