remote

package
v0.0.0-...-173ccf6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2018 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Overview

Package remote provides the remoting facilities for agentless execution. This set of structs and methods are for running mgmt remotely over SSH. This gives us the architectural robustness of our current design, combined with the ability to run it with an "agent-less" approach for bootstrapping, and in environments with more restrictive installation requirements. In general the following sequence is run:

  1. connect to remote host
  2. make temporary directory
  3. copy over the mgmt binary and graph definition
  4. tunnel tcp connections for etcd
  5. run it!
  6. finish and quit
  7. close tunnels
  8. clean up
  9. disconnect

The main advantage of this agent-less approach, is while multiple of these remote mgmt transient agents are running, they can still exchange data and converge together without directly connecting, since they all tunnel through the etcd server running on the initiator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Flags

type Flags struct {
	Program string
	Debug   bool
}

Flags are constants required by the remote lib.

type Remotes

type Remotes struct {
	// contains filtered or unexported fields
}

The Remotes struct manages a set of SSH connections. TODO: rename this to something more logical

func NewRemotes

func NewRemotes(clientURLs, remoteURLs []string, noop bool, remotes []string, fileWatch chan string, cConns uint16, interactive bool, sshPrivIDRsa string, caching bool, depth uint16, prefix string, converger cv.Converger, convergerCb func(func(map[string]bool) error) (func(), error), flags Flags) *Remotes

NewRemotes builds a Remotes struct.

func (*Remotes) Exit

func (obj *Remotes) Exit() error

Exit causes as much of the Remotes struct to shutdown as quickly and as cleanly as possible. It only returns once everything is shutdown.

func (*Remotes) NewSSH

func (obj *Remotes) NewSSH(file string) (*SSH, error)

NewSSH is a helper function that does the initial parsing into an SSH obj. It takes as input the path to a graph definition file.

func (*Remotes) Ready

func (obj *Remotes) Ready() <-chan struct{}

Ready closes its returned channel when the Run method is up and ready. It is useful to know when ready, since we often execute Run in a go routine.

func (*Remotes) Run

func (obj *Remotes) Run()

Run kicks it all off. It is usually run from a go routine.

type SSH

type SSH struct {
	// contains filtered or unexported fields
}

The SSH struct is the unit building block for a single remote SSH connection.

func (*SSH) Close

func (obj *SSH) Close() error

Close cleans up after the main SSH connection.

func (*SSH) Connect

func (obj *SSH) Connect() error

Connect kicks off the SSH connection.

func (*SSH) Exec

func (obj *SSH) Exec() error

Exec runs the binary on the remote server.

func (*SSH) ExecExit

func (obj *SSH) ExecExit() error

ExecExit sends a SIGINT (^C) signal to the remote process, and waits for the process to exit.

func (*SSH) Go

func (obj *SSH) Go() error

Go kicks off the entire sequence of one SSH connection.

func (*SSH) Sftp

func (obj *SSH) Sftp() error

Sftp is a function for the sftp protocol to create a remote dir and copy over the binary to run. On error the string represents the path to the remote dir.

func (*SSH) SftpClean

func (obj *SSH) SftpClean() error

SftpClean cleans up the mess and closes the connection from the sftp work.

func (*SSH) SftpCopy

func (obj *SSH) SftpCopy(src, dst string) (int64, error)

SftpCopy is a simple helper function that runs a local -> remote sftp copy.

func (*SSH) SftpGraphCopy

func (obj *SSH) SftpGraphCopy() (int64, error)

SftpGraphCopy is a helper function used for re-copying the graph definition.

func (*SSH) SftpHash

func (obj *SSH) SftpHash(local, remote string) (bool, error)

SftpHash hashes a local file, and compares that hash to the result of a remote hashing command run on the second file path.

func (*SSH) Stop

func (obj *SSH) Stop() error

Stop shuts down any SSH in progress as safely and quickly as possible.

func (*SSH) Tunnel

func (obj *SSH) Tunnel() error

Tunnel initiates the reverse SSH tunnel. You can .Wait() on the returned sync WaitGroup to know when the tunnels have closed completely.

func (*SSH) TunnelClose

func (obj *SSH) TunnelClose() error

TunnelClose causes any currently connected Tunnel to shutdown.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL