platform

package
v3.2.10 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: LGPL-3.0 Imports: 25 Imported by: 0

Documentation

Overview

Package platform contains interface and implementation to run onet code amongst multiple platforms. Such implementations include Localhost (run your test locally) and Deterlab (similar to emulab).

Index

Constants

This section is empty.

Variables

View Source
var ErrorFieldNotPresent = xerrors.New("field not present")

ErrorFieldNotPresent signals that a field is not in the RunConfig.

Functions

func Build

func Build(path, out, goarch, goos string, buildArgs ...string) (string, error)

Build builds the the golang packages in `path` and stores the result in `out`. Besides specifying the environment variables GOOS and GOARCH you can pass any additional argument using the buildArgs argument. The command which will be executed is of the following form: $ go build -v buildArgs... -o out path

func CheckOutOfFileDescriptors

func CheckOutOfFileDescriptors() error

CheckOutOfFileDescriptors tries to duplicate the stdout file descriptor and throws an error if it cannot do it. This is a horrible hack mainly for MacOSX where the file descriptor limit is quite low and we need to tell people running simulations what they can do about it.

func KillGo

func KillGo()

KillGo kills all go-instances

func Rsync

func Rsync(username, host, file, dest string) error

Rsync copies files or directories to the remote host. If the DebugVisible is > 1, the rsync-operation is displayed on screen.

func SSHRun

func SSHRun(username, host, command string) ([]byte, error)

SSHRun runs a command on the remote host

func SSHRunStdout

func SSHRunStdout(username, host, command string) error

SSHRunStdout runs a command on the remote host but redirects stdout and stderr of the Ssh-command to the os.Stderr and os.Stdout

func Scp

func Scp(username, host, file, dest string) error

Scp copies the given files to the remote host

func Simulate

func Simulate(suite, serverAddress, simul, monitorAddress string) error

Simulate starts the server and will setup the protocol.

Types

type Config

type Config struct {
	// string denoting the group used for simulations
	// XXX find ways to remove that "one suite" assumption
	Suite       string
	MonitorPort int
	Debug       int
}

Config is passed to Platform.Config and prepares the platform for specific system-wide configurations

type Deterlab

type Deterlab struct {
	// *** Deterlab-related configuration
	// The login on the platform
	Login string
	// The outside host on the platform
	Host string
	// The name of the project
	Project string
	// Name of the Experiment - also name of hosts
	Experiment string

	// DNS-resolvable names
	Phys []string
	// VLAN-IP names (physical machines)
	Virt []string

	// ProxyAddress : the proxy will redirect every traffic it
	// receives to this address
	ProxyAddress string
	// MonitorAddress is the address given to clients to connect to the monitor
	// It is actually the Proxy that will listen to that address and clients
	// won't know a thing about it
	MonitorAddress string
	// Port number of the monitor and the proxy
	MonitorPort int

	// Number of available servers
	Servers int
	// Name of the simulation
	Simulation string
	// Number of machines
	Hosts int
	// Debugging-level: 0 is none - 5 is everything
	Debug int
	// RunWait for long simulations
	RunWait string
	// suite used for the simulation
	Suite string
	// PreScript defines a script that is run before the simulation
	PreScript string
	// Tags to use when compiling
	Tags string
	// contains filtered or unexported fields
}

Deterlab holds all fields necessary for a Deterlab-run

func (*Deterlab) Build

func (d *Deterlab) Build(build string, arg ...string) error

Build prepares all binaries for the Deterlab-simulation. If 'build' is empty, all binaries are created, else only the ones indicated. Either "simul" or "users"

func (*Deterlab) Cleanup

func (d *Deterlab) Cleanup() error

Cleanup kills all eventually remaining processes from the last Deploy-run

func (*Deterlab) Configure

func (d *Deterlab) Configure(pc *Config)

Configure initialises the directories and loads the saved config for Deterlab

func (*Deterlab) Deploy

func (d *Deterlab) Deploy(rc *RunConfig) error

Deploy creates the appropriate configuration-files and copies everything to the deterlab-installation.

func (*Deterlab) Start

func (d *Deterlab) Start(args ...string) error

Start creates a tunnel for the monitor-output and contacts the Deterlab- server to run the simulation

func (*Deterlab) Wait

func (d *Deterlab) Wait() error

Wait for the process to finish

type Localhost

type Localhost struct {
	// Need mutex because build.go has a global variable that
	// is used for multiple experiments
	sync.Mutex

	// The simulation to run
	Simulation string

	// Suite used for the simulation
	Suite string

	// PreScript is run before the simulation is started
	PreScript string

	// RunWait for long simulations
	RunWait string
	// contains filtered or unexported fields
}

Localhost is the platform for launching thee apps locally

func (*Localhost) Build

func (d *Localhost) Build(build string, arg ...string) error

Build does nothing, as we're using our own binary, no need to build

func (*Localhost) Cleanup

func (d *Localhost) Cleanup() error

Cleanup kills all running cothority-binaryes

func (*Localhost) Configure

func (d *Localhost) Configure(pc *Config)

Configure various internal variables

func (*Localhost) Deploy

func (d *Localhost) Deploy(rc *RunConfig) error

Deploy copies all files to the run-directory

func (*Localhost) Start

func (d *Localhost) Start(args ...string) error

Start will execute one cothority-binary for each server configured

func (*Localhost) Wait

func (d *Localhost) Wait() error

Wait for all processes to finish

type MiniNet

type MiniNet struct {
	// *** Mininet-related configuration
	// The login on the platform
	Login string
	// The outside host on the platform
	External string

	// IPs of all hosts
	HostIPs []string

	// ProxyAddress : the proxy will redirect every traffic it
	// receives to this address
	ProxyAddress string
	// Port number of the monitor and the proxy
	MonitorPort int

	// Simulation to be run
	Simulation string
	// Number of servers to be used
	Servers int
	// Number of machines
	Hosts int
	// Debugging-level: 0 is none - 5 is everything
	Debug int
	// Whether to show time in debugging messages
	DebugTime bool
	// Whether to show color debugging-messages
	DebugColor bool
	// Whether to pad debugging-messages
	DebugPadding bool
	// The number of seconds to wait for closing the connection
	RunWait string
	// Delay in ms of the network connection
	Delay int
	// Bandwidth in Mbps of the network connection
	Bandwidth int
	// Suite used for the simulation
	Suite string
	// PreScript defines a script that is run before the simulation
	PreScript string
	// Tags to use when compiling
	Tags string
	// contains filtered or unexported fields
}

MiniNet represents all the configuration that is necessary to run a simulation on remote hosts running Mininet.

func (*MiniNet) Build

func (m *MiniNet) Build(build string, arg ...string) error

Build implements the Platform interface and is called once per runlevel-file. build is the name of the app to build empty = all otherwise build specific package

func (*MiniNet) Cleanup

func (m *MiniNet) Cleanup() error

Cleanup kills all eventually remaining processes from the last Deploy-run

func (*MiniNet) Configure

func (m *MiniNet) Configure(pc *Config)

Configure implements the Platform-interface. It is called once to set up the necessary internal variables.

func (*MiniNet) Deploy

func (m *MiniNet) Deploy(rc *RunConfig) error

Deploy creates the appropriate configuration-files and copies everything to the MiniNet-installation.

func (*MiniNet) Start

func (m *MiniNet) Start(args ...string) error

Start connects to the first of the remote servers to start the simulation.

func (*MiniNet) Wait

func (m *MiniNet) Wait() error

Wait blocks on the channel till the main-process finishes.

type Platform

type Platform interface {
	// Does the initial configuration of all structures needed for the platform
	Configure(*Config)
	// Build builds all necessary binaries
	Build(build string, arg ...string) error
	// Makes sure that there is no part of the application still running
	Cleanup() error
	// Copies the binaries to the appropriate directory/machines, together with
	// the necessary configuration. RunConfig is a simple string that should
	// be copied as 'app.toml' to the directory where the app resides
	Deploy(*RunConfig) error
	// Starts the application and returns - non-blocking!
	Start(args ...string) error
	// Waits for the application to quit
	Wait() error
}

Platform interface that has to be implemented to add another simulation- platform.

func NewPlatform

func NewPlatform(t string) Platform

NewPlatform returns the appropriate platform [deterlab,localhost]

type RunConfig

type RunConfig struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

RunConfig is a struct that represent the configuration to apply for one "test" Note: a "simulation" is a set of "tests"

func NewRunConfig

func NewRunConfig() *RunConfig

NewRunConfig returns an initialised config to be used for reading in runconfig-files

func ReadRunFile

func ReadRunFile(p Platform, filename string) []*RunConfig

ReadRunFile reads from a configuration-file for a run. The configuration-file has the following syntax: Name1 = value1 Name2 = value2 [empty line] n1, n2, n3, n4 v11, v12, v13, v14 v21, v22, v23, v24

The Name1...Namen are global configuration-options. n1..nn are configuration-options for one run Both the global and the run-configuration are copied to both the platform and the app-configuration.

func (*RunConfig) Clone

func (r *RunConfig) Clone() *RunConfig

Clone this runconfig so it has all fields-value relationship already present

func (*RunConfig) Delete

func (r *RunConfig) Delete(field string)

Delete a field from the runconfig (delete for example Simulation which we dont care in the final csv)

func (*RunConfig) Get

func (r *RunConfig) Get(field string) string

Get returns the associated value of the field in the config

func (*RunConfig) GetBuckets

func (r *RunConfig) GetBuckets() ([][]string, error)

GetBuckets returns the list of buckets defined in the configuration file to split the statistics

func (*RunConfig) GetDuration

func (r *RunConfig) GetDuration(field string) (time.Duration, error)

GetDuration returns the field parsed as a duration, or error if a parse error occurs.

func (*RunConfig) GetInt

func (r *RunConfig) GetInt(field string) (int, error)

GetInt returns the integer of the field, or error if not defined

func (*RunConfig) Map

func (r *RunConfig) Map() map[string]string

Map returns this config as a Map

func (*RunConfig) Put

func (r *RunConfig) Put(field, value string)

Put inserts a new field - value relationship

func (*RunConfig) String

func (r *RunConfig) String() string

func (*RunConfig) Toml

func (r *RunConfig) Toml() []byte

Toml returns this config as bytes in a Toml format

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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