helpers

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: May 11, 2019 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package helpers contains functions to help make the task of deploying a blockchain easier and faster

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllNewNodeExecCon

func AllNewNodeExecCon(tn *testnet.TestNet, fn func(*ssh.Client, *db.Server, ssh.Node) error) error

AllNewNodeExecCon is AllNodeExecCon but executes only for new nodes

func AllNewNodeExecConSC added in v1.7.1

func AllNewNodeExecConSC(ad *testnet.Adjunct, fn func(*ssh.Client, *db.Server, ssh.Node) error) error

AllNewNodeExecConSC is AllNewNodeExecCon but executes only for sidecar nodes

func AllNodeExecCon

func AllNodeExecCon(tn *testnet.TestNet, fn func(*ssh.Client, *db.Server, ssh.Node) error) error

AllNodeExecCon executes fn for every node concurrently. Will return once all of the calls to fn have been completely. Each call to fn is provided with, in order, the relevant ssh client, the server where the node exists, the local number of that node on the server and the absolute number of the node in the testnet. If any of the calls to fn return a non-nil error value, one of those errors will be returned. Currently there is no guarentee as to which one, however this should be implemented in the future.

func AllNodeExecConSC added in v1.7.1

func AllNodeExecConSC(ad *testnet.Adjunct, fn func(*ssh.Client, *db.Server, ssh.Node) error) error

AllNodeExecConSC is AllNodeExecCon but executes only for sidecar nodes

func AllServerExecCon

func AllServerExecCon(tn *testnet.TestNet, fn func(*ssh.Client, *db.Server) error) error

AllServerExecCon executes fn for every server in the testnet. Is sementatically similar to AllNodeExecCon. Every call to fn is provided with the relevant ssh client and server object.

func AllServerExecConSC added in v1.7.1

func AllServerExecConSC(ad *testnet.Adjunct, fn func(*ssh.Client, *db.Server) error) error

AllServerExecConSC is like AllServerExecCon but for side cars

func CheckDeployFlag

func CheckDeployFlag(details *db.DeploymentDetails, flag string) bool

CheckDeployFlag checks for the presence of an extras flag.

func CopyAllToServers

func CopyAllToServers(tn *testnet.TestNet, srcDst ...string) error

CopyAllToServers copies all of the src files to all of the servers within the given testnet. This can handle multiple pairs in form of ...,source,destination,source2,destination2

func CopyBytesToAllNewNodes

func CopyBytesToAllNewNodes(tn *testnet.TestNet, dataDst ...string) error

CopyBytesToAllNewNodes is CopyBytesToAllNodes but only operates on newly built nodes

func CopyBytesToAllNewNodesSC added in v1.7.1

func CopyBytesToAllNewNodesSC(ad *testnet.Adjunct, dataDst ...string) error

CopyBytesToAllNewNodesSC is CopyBytesToAllNewNodes but only operates on sidecar nodes

func CopyBytesToAllNodes

func CopyBytesToAllNodes(tn *testnet.TestNet, dataDst ...string) error

CopyBytesToAllNodes functions similiarly to CopyToAllNodes, except it operates on data and dst pairs instead of src and dest pairs, so you can just pass data directly to all of the nodes without having to call buildState.Write first.

func CopyBytesToAllNodesSC added in v1.7.1

func CopyBytesToAllNodesSC(ad *testnet.Adjunct, dataDst ...string) error

CopyBytesToAllNodesSC is CopyBytesToAllNodes but only operates on sidecar nodes

func CopyToAllNewNodes

func CopyToAllNewNodes(tn *testnet.TestNet, srcDst ...string) error

CopyToAllNewNodes copies files writen with BuildState's write function over to all of the newly built nodes. Can handle multiple files, in pairs of src and dst

func CopyToAllNewNodesSC added in v1.7.1

func CopyToAllNewNodesSC(ad *testnet.Adjunct, srcDst ...string) error

CopyToAllNewNodesSC is CopyToAllNewNodes for side cars

func CopyToAllNodes

func CopyToAllNodes(tn *testnet.TestNet, srcDst ...string) error

CopyToAllNodes copies files writen with BuildState's write function over to all of the nodes. Can handle multiple files, in pairs of src and dst

func CopyToAllNodesSC added in v1.7.1

func CopyToAllNodesSC(ad *testnet.Adjunct, srcDst ...string) error

CopyToAllNodesSC is CopyToAllNodes for side cars

func CreateConfigs

func CreateConfigs(tn *testnet.TestNet, dest string, fn func(ssh.Node) ([]byte, error)) error

CreateConfigs allows for individual generation of configuration files with error propogation. For each node, fn will be called, with (Server ID, local node number, absolute node number), and it will expect to have the configuration file returned or error.

func CreateConfigsNewNodes

func CreateConfigsNewNodes(tn *testnet.TestNet, dest string, fn func(ssh.Node) ([]byte, error)) error

CreateConfigsNewNodes is CreateConfigs but it only operates on new nodes

func CreateConfigsNewNodesSC added in v1.7.1

func CreateConfigsNewNodesSC(ad *testnet.Adjunct, dest string, fn func(ssh.Node) ([]byte, error)) error

CreateConfigsNewNodesSC is CreateConfigsNewNodes but it only operates on side cars

func CreateConfigsSC added in v1.7.1

func CreateConfigsSC(ad *testnet.Adjunct, dest string, fn func(ssh.Node) ([]byte, error)) error

CreateConfigsSC is CreateConfigs but it only operates on side cars

func GetBlockchainConfig

func GetBlockchainConfig(blockchain string, node int, file string, details *db.DeploymentDetails) ([]byte, error)

GetBlockchainConfig fetches dynamic config template files for the blockchain. Should be used in most cases instead of GetStaticBlockchainConfig as it provides the user the functionality for `-t..` in the build command for the CLI

func GetDefaults

func GetDefaults(details *db.DeploymentDetails, term string) (interface{}, bool)

GetDefaults get any availible default value for a given term. will be nil,false if it is not found

func GetFileDefault

func GetFileDefault(details *db.DeploymentDetails, file string) (string, bool)

GetFileDefault gets the default value for a file if it exists in the extras

func GetStaticBlockchainConfig

func GetStaticBlockchainConfig(blockchain string, file string) ([]byte, error)

GetStaticBlockchainConfig fetches a static file resource for a blockchain, which will never change

func ScpAndDeferRemoval

func ScpAndDeferRemoval(client *ssh.Client, buildState *state.BuildState, src string, dst string)

ScpAndDeferRemoval Copy a file over to a server, and then defer it for removal after the build is completed

func SingleCp

func SingleCp(client *ssh.Client, buildState *state.BuildState, node ssh.Node, data []byte, dest string) error

SingleCp copies over data to the given dest on node localNodeID.

Types

type KeyMaster

type KeyMaster struct {
	//PrivateKeys contains the static pool of private keys
	PrivateKeys []string
	//PublicKeys contains the static pool of private keys.
	PublicKeys []string
	// contains filtered or unexported fields
}

KeyMaster is a static resource key manager Uses keys stored in the blockchains resource directory, so that keys can remain consistent among builds and also to save time on builds where a large number of keys are needed. Note: This is not thread safe and may need external synchronization.

func NewKeyMaster

func NewKeyMaster(details *db.DeploymentDetails, blockchain string) (*KeyMaster, error)

NewKeyMaster creates a new KeyMaster using the provided deployment details and blockchain. Currently details is not used, but in the future, it should be used to allow the user to provide their own static keys to be used in the pool.

func (*KeyMaster) AddGenerator

func (km *KeyMaster) AddGenerator(gen func(client *ssh.Client) (util.KeyPair, error))

AddGenerator sets the backup key generator function for km KeyMaster

func (*KeyMaster) GenerateKeyPair

func (km *KeyMaster) GenerateKeyPair(client *ssh.Client) (util.KeyPair, error)

GenerateKeyPair generates a new key pair if a generator function has been provided

func (*KeyMaster) GetKeyPair

func (km *KeyMaster) GetKeyPair(client *ssh.Client) (util.KeyPair, error)

GetKeyPair fetches a key pair, will use up keys in the static pool until it runs out, if it runs out, it will use the given generator to create new keys

func (*KeyMaster) GetMappedKeyPairs

func (km *KeyMaster) GetMappedKeyPairs(args []string, client *ssh.Client) (map[string]util.KeyPair, error)

GetMappedKeyPairs returns key pairs mapped to arbitrary string values. Useful for named key pairs

func (*KeyMaster) GetServerKeyPairs

func (km *KeyMaster) GetServerKeyPairs(servers []db.Server, clients []*ssh.Client) (map[string]util.KeyPair, error)

GetServerKeyPairs is DEPRECATED, but maps the ip addresses of nodes to their own key pair

Jump to

Keyboard shortcuts

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