util

package
v0.0.0-...-ffb99a7 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAuthorizedPublicKey

func AddAuthorizedPublicKey(username string, publicKeyFilename string) error

AddAuthorizedPublicKey appends the public key in `publicKeyFilename` into the file `.ssh/authorized_keys` within the home directory of `username`.

func GenerateRSAKeyPair

func GenerateRSAKeyPair(savePrivateFileTo string, savePublicFileTo string) error

GenerateRSAKeyPair creates RSK key pairs within a given location.

func GetSyscallCredential

func GetSyscallCredential(username string) (*syscall.Credential, error)

GetSyscallCredential returns the `syscall.Credential` structure of the given system `username`.

Types

type Connector

type Connector interface {
	NewClient(remoteServer string, clientConfig *ssh.ClientConfig) (*ssh.Client, error)
	NewSession(client *ssh.Client) (*ssh.Session, error)
	Run(session *ssh.Session, command string) error
	CombinedOutput(session *ssh.Session, command string) ([]byte, error)
	CloseSession(session *ssh.Session) error
	CloseConnection(client *ssh.Client)
}

Connector is an interface to be able to mock SSH connections

type Payload

type Payload struct {
	// // EndPointRadarbase is the endpoint of the radarbase platform.
	// EndPointRadarbase string `json:"radarbaseURL"`
	// UserID is the user id the raw data concerns.
	UserID string `json:"userID"`
	// SessionID is the experiment session id the raw data concerns.
	SessionID string `json:"sessionID"`
	// OutputDir is the filesystem path where the output data is to
	// be stored.
	OutputDir string `json:"outputDirectory"`
}

Payload is the data structure for the feature extraction payload.

func (Payload) Run

func (p Payload) Run(runas string) (string, error)

Run executes the feature extraction payload on local host, using the `runas` user credential.

func (Payload) SSHSubmit

func (p Payload) SSHSubmit(username, jobReq, jobQueue, sshHost, privateKeyFile string) (string, error)

SSHSubmit submits jobs via HPC's access node, using SSH. It requires pubkey authentication to be established between server and the remote user account.

func (Payload) String

func (p Payload) String() string

String is a string representation of the payload.

func (Payload) Submit

func (p Payload) Submit(runas, jobReq, jobQueue string) (string, error)

Submit sends the feature extraction payload to be run on the HPC cluster. The job is submitted under the credential `runas`.

type SSHConnector

type SSHConnector struct {
	Description string
}

SSHConnector is used tp replace the standard SSH library functions

func (SSHConnector) CloseConnection

func (c SSHConnector) CloseConnection(client *ssh.Client)

CloseConnection makes it possible to mock the closing of a session

func (SSHConnector) CloseSession

func (c SSHConnector) CloseSession(session *ssh.Session) error

CloseSession makes it possible to mock the closing of a session

func (SSHConnector) CombinedOutput

func (c SSHConnector) CombinedOutput(session *ssh.Session, command string) ([]byte, error)

CombinedOutput makes it possible to mock a local CombinedOutput

func (SSHConnector) NewClient

func (c SSHConnector) NewClient(remoteServer string, clientConfig *ssh.ClientConfig) (*ssh.Client, error)

NewClient makes it possible to mock SSH dial

func (SSHConnector) NewSession

func (c SSHConnector) NewSession(client *ssh.Client) (*ssh.Session, error)

NewSession makes it possible to mock a SSH session

func (SSHConnector) Run

func (c SSHConnector) Run(session *ssh.Session, command string) error

Run makes it possible to mock a remote Run command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳