Documentation ¶
Index ¶
- func ConfigureAgentCommandRunDetached(command string) (string, error)
- func Distribute(command string, nodes ...Node) error
- func NewNodePool(nodes []Node, alloced []string) *nodePool
- func Run(node Node, command string, w io.Writer) (err error)
- func ScpText(node Node, remoteFile string, localFile io.Writer) error
- func UploadUpdate(ctx context.Context, provisioner Provisioner, installer Node) (err error)
- type Config
- type ExternalStateLoader
- type Infra
- type Node
- type NodePool
- type Nodes
- type Provisioner
- type ProvisionerState
- type StateNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigureAgentCommandRunDetached ¶
ConfigureAgentCommandRunDetached interprets command as an agent download command and modifies it to execute the agent in background. For example:
curl -s --tlsv1.2 --insecure -a="foo bar" "https://example.com/t/12437/node" | sudo bash
will be modified to become:
curl -s --tlsv1.2 --insecure -a="foo bar" "https://example.com/t/12437/node?bg=true" | sudo bash
The function assumes that the pipeline contains a CURL command - otherwise it will fail.
func Distribute ¶
Distribute executes the specified command on given nodes and waits for execution to complete before returning
func NewNodePool ¶
NewNodePool creates a new instance of NodePool from specified nodes and allocation state
func Run ¶
Run executes the specified command on node and streams session's Stdout/Stderr to the specified w
func UploadUpdate ¶
func UploadUpdate(ctx context.Context, provisioner Provisioner, installer Node) (err error)
UploadUpdate uploads a new application version to the installer node
Types ¶
type Config ¶
type Config struct { // ClusterName is the name assigned to the provisioned machines ClusterName string `json:"cluster_name" ` }
type ExternalStateLoader ¶
type ExternalStateLoader interface { // LoadFromExternalState loads the state from the specified reader r. // withInstaller controls whether the installer address information // is also retrieved. // Returns the installer node if requested. LoadFromExternalState(r io.Reader, withInstaller bool) (installer Node, err error) }
ExternalStateLoader loads provisioner state from external source
type Infra ¶
type Infra interface { // OpsCenterURL returns the address of the Ops Center this infrastructure describes. // This can be an existing Ops Center or the one created using the provided provisioner // running the wizard OpsCenterURL() string // Close releases resources Close() error // Destroy destroys the cluster (e.g. deprovisions nodes, etc.) Destroy() error // Provisioner returns the provisioner used to manage nodes in the cluster. // If the provisioner is nil, the cluster is assumed to use automatic // provisioning Provisioner() Provisioner // Config returns a configuration this infrastructure object was created with Config() Config }
Infra describes the infrastructure as used in tests.
Infrastructure can be a new cluster that is provisioned as part of the test run using one of the built-in provisioners, or an active cluster and Ops Center to run tests that require existing infrastructure
func New ¶
func New(config Config, opsCenterURL string, provisioner Provisioner) (Infra, error)
New creates a new cluster from the specified config and an optional provisioner. If no provisioner is specified, automatic provisioning is assumed
func NewWizard ¶
NewWizard creates a new cluster using an installer tarball (which is assumed to be part of the configuration). It provisions a cluster, picks an installer node and starts a local wizard process. Returns the reference to the created infrastructure and the application package the wizard is installing
type Node ¶
type Node interface { fmt.Stringer // Addr returns public address of the node Addr() string // PrivateAddr returns the private address of the node PrivateAddr() string // Connect connects to this node and returns a new session object // that can be used to execute remote commands Connect() (*ssh.Session, error) // Client connects to this node and returns a new SSH Client object // that can be used to execute remote commands Client() (*ssh.Client, error) }
Node defines an interface to a remote node
type NodePool ¶
type NodePool interface { // Nodes returns all nodes in this pool Nodes() []Node // AllocatedNodes returns only allocated nodes in this pool AllocatedNodes() []Node // Node looks up a node given with addr. // Returns error if no node matches the specified addr Node(addr string) (Node, error) // Size returns the number of nodes in this pool Size() int // SizeAllocated returns the number of allocated nodes in this pool SizeAllocated() int // Allocate allocates amount new nodes from the pool and returns // a slice of allocated nodes Allocate(amount int) ([]Node, error) // Free releases specified nodes back to the node pool Free([]Node) error }
NodePool manages node allocation/release for a provisioner
type Provisioner ¶
type Provisioner interface { // Create provisions a new cluster and returns a reference // to the node that can be used to run installation // // withInstaller specifies if the provisioner should select an installer node. // Installer node selection is provisioner-specific Create(ctx context.Context, withInstaller bool) (installer Node, err error) // Destroy the infrastructures created by Create. // After the call to Destroy the provisioner is invalid and no // other methods can be used Destroy(ctx context.Context) error // Connect connects to the node identified with addr and returns // a new session object that can be used to execute remote commands Connect(addr string) (*ssh.Session, error) // Client connects to the node identified with addr and returns // a new ssh client that can be used to execute remote commands Client(addr string) (*ssh.Client, error) // SelectInterface returns the index (in addrs) of network address to use for // installation. // installerNode should be the result of calling Provisioner.Create // addrs is guaranteed to have at least one element SelectInterface(installer Node, addrs []string) (int, error) // StartInstall initiates installation in the specified session StartInstall(session *ssh.Session) error // UploadUpdate initiates uploading of new application version // in the specified session UploadUpdate(session *ssh.Session) error // Pool returns a reference to the managing node pool NodePool() NodePool // InstallerLogPath returns remote path to the installer log file InstallerLogPath() string // State returns the state of this provisioner State() ProvisionerState }
Provisioner defines a means of creating a cluster from scratch and managing the nodes.
Cluster can be created with a pool of nodes only a subset of which is active at any given time. When the cluster is created with capacity bigger than the subset of nodes used for installation, then the initially unused nodes can be Allocated (and Deallocated) on demand to enable expand/shrink test workflows.
type ProvisionerState ¶
type ProvisionerState struct { // Dir defines the location where provisioner stores state Dir string `json:"state_dir,omitempty"` // InstallerAddr is the address of the installer node InstallerAddr string `json:"installer_addr,omitempty"` // Nodes is a list of all nodes in the cluster Nodes []StateNode `json:"nodes"` // Allocated defines the allocated subset Allocated []string `json:"allocated_nodes"` // Specific defines provisioner-specific state Specific json.Marshaler }
ProvisionerState defines the state configuration for a cluster provisioned with a specific provisioner