all repos — memnarch @ 3d31dd24b24de57ae31e0ac33c2446af9acf31cc

featherweight orchestrator

hosts: mostly implement Host.Run()
Iris Lightshard nilix@nilfm.cc
PGP Signature
-----BEGIN PGP SIGNATURE-----

iHUEABYKAB0WIQR2zYvweXfSPsSU6pP1Tg1AaVJx1AUCZXagFgAKCRD1Tg1AaVJx
1GVFAPoCcSRCxI9Dn3267YYHMXWylg2jpy/O9dE2OlMiTUTFqwEAgSXPu8p0QIzB
bGTYOVgWacZFQ4qfjxSx3bYZfbJFqQg=
=yFqf
-----END PGP SIGNATURE-----
commit

3d31dd24b24de57ae31e0ac33c2446af9acf31cc

parent

c28267af045fccf922a7eb484b8b6844019305ab

1 files changed, 30 insertions(+), 1 deletions(-)

jump to
M hosts/hosts.gohosts/hosts.go

@@ -1,5 +1,13 @@

package hosts +import ( + "errors" + "fmt" + "os" + "os/exec" + "path/filepath" +) + // a host is a name and an address // memnarch expects an SSH private key to connect to Addr to exist at MEMNARCH_HOSTS/Name

@@ -12,6 +20,27 @@ type RemoteMachine interface {

Run(...string) error } -func (*Host) Run(cmdArgs ...string) error { +func (self *Host) Run(cmdArgs ...string) error { + // make sure keyfile exists + keysDir := os.Getenv("MEMNARCH_HOSTS") + keyfile := filepath.Join(keysDir, self.Name) + info, err := os.Stat(keyfile) + if (err != nil) { + return err + } + if (info.IsDir()) { + return errors.New("supposed keyfile is actually a directory") + } + // ssh in + completeArgs := append([]string{"-i", keyfile, "memnarch@"+self.Addr}, cmdArgs...) + sshCmd := exec.Command("ssh", completeArgs...) + output, err := sshCmd.CombinedOutput() + // TODO: log the metadata + fmt.Println(output) + // if error, return it + if err != nil { + return err + } + // otherwise... return nil }