Help us shape the future of Go! Take the 2026 Go Developer Survey

datasource

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2016 License: GPL-2.0 Imports: 19 Imported by: 10

Documentation

Overview

Package datasource pacakge creates means of interacting with the external datasources for blacksmith

Index

Constants

View Source
const (
	ActiveMasterUpdateTime  = 10 * time.Second
	StandbyMasterUpdateTime = 15 * time.Second
)
View Source
const (
	// SpecialKeyCoreosVersion is a special key for the coreos version of the machines
	SpecialKeyCoreosVersion = "coreos-version"
	// SpecialKeyNetworkConfiguration is a special key for the network of the cluster
	SpecialKeyNetworkConfiguration = "net-conf"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClasslessRouteOptionPart added in v0.9.2

type ClasslessRouteOptionPart struct {
	Router      net.IP `json:"router"`
	Size        byte   `json:"size"`
	Destination net.IP `json:"destination"`
}

ClasslessRouteOptionPart is the static route which consists of a destination descriptor and the IP address of the router that should be used to reach that destination. https://tools.ietf.org/html/rfc3442

func (*ClasslessRouteOptionPart) ToBytes added in v0.9.2

func (c *ClasslessRouteOptionPart) ToBytes() []byte

ToBytes formats the static route according to rfc3442

type DataSource

type DataSource interface {
	// SelfInfo return InstanceInfo of this instance of blacksmith
	SelfInfo() InstanceInfo

	// Instances returns the InstanceInfo of all the present instances of
	// blacksmith in our cluster
	Instances() ([]InstanceInfo, error)

	// IsMaster checks for being master
	IsMaster() error

	// WhileMaster makes a heartbeat and returns IsMaster()
	WhileMaster() error

	// Shutdown removes the instance key from the list of instances, used to
	// gracefully shutdown the instance
	Shutdown() error

	// ClusterName returns the name of the ClusterName
	ClusterName() string

	// WorkspacePath returns the path to the workspace which is used after the
	// machines are booted up
	WorkspacePath() string

	// MachineInterfaces returns all the machines in the cluster, as a slice of
	// MachineInterfaces
	MachineInterfaces() ([]MachineInterface, error)

	// MachineInterface returns the MachineInterface associated with the given
	// mac
	MachineInterface(mac net.HardwareAddr) MachineInterface

	// ListClusterVariables returns the list of all the cluster variables
	ListClusterVariables() (map[string]string, error)

	// GetClusterVariable returns a cluster variables with the given name
	GetClusterVariable(key string) (string, error)

	// SetClusterVariable sets a cluster variable
	SetClusterVariable(key string, value string) error

	// DeleteClusterVariable delete a cluster variable from etcd.
	DeleteClusterVariable(key string) error

	// EtcdMembers returns a string suitable for `-initial-cluster`
	// This is the etcd the Blacksmith instance is using as its datastore
	// Smelly function to be here! but it's a lot helpful.
	EtcdMembers() (string, error)
}

DataSource provides the interface for querying general information

func ForTest added in v0.9.3

func ForTest(t *testing.T) DataSource

ForTest constructs a DataSource to be used in tests

func NewEtcdDataSource

func NewEtcdDataSource(kapi etcd.KeysAPI, client etcd.Client, leaseStart net.IP,
	leaseRange int, clusterName, workspacePath string, defaultNameServers []string,
	selfInfo InstanceInfo) (DataSource, error)

NewEtcdDataSource gives blacksmith the ability to use an etcd endpoint as a MasterDataSource

type EtcdDataSource

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

EtcdDataSource implements MasterDataSource interface using etcd as it's datasource Implements MasterDataSource interface

func (*EtcdDataSource) ClusterName

func (ds *EtcdDataSource) ClusterName() string

ClusterName returns the name of the cluster

func (*EtcdDataSource) DeleteClusterVariable added in v0.9.2

func (ds *EtcdDataSource) DeleteClusterVariable(key string) error

DeleteClusterVariable deletes a cluster variable

func (*EtcdDataSource) EtcdMembers added in v0.9.2

func (ds *EtcdDataSource) EtcdMembers() (string, error)

EtcdMembers returns a string suitable for `-initial-cluster` This is the etcd the Blacksmith instance is using as its datastore

func (*EtcdDataSource) GetClusterVariable added in v0.9.2

func (ds *EtcdDataSource) GetClusterVariable(key string) (string, error)

GetClusterVariable returns a cluster variables with the given name

func (*EtcdDataSource) Instances added in v0.9.2

func (ds *EtcdDataSource) Instances() ([]InstanceInfo, error)

Instances returns the InstanceInfo of all the present instances of blacksmith in our cluster

func (*EtcdDataSource) IsMaster

func (ds *EtcdDataSource) IsMaster() error

IsMaster checks for being master

func (*EtcdDataSource) ListClusterVariables added in v0.9.2

func (ds *EtcdDataSource) ListClusterVariables() (map[string]string, error)

ListClusterVariables returns the list of all the cluster variables from etcd

func (*EtcdDataSource) ListConfigurations added in v0.9.2

func (ds *EtcdDataSource) ListConfigurations() (map[string]string, error)

ListConfigurations returns the list of all the configuration variables from etcd

func (*EtcdDataSource) MachineInterface added in v0.9.2

func (ds *EtcdDataSource) MachineInterface(mac net.HardwareAddr) MachineInterface

MachineInterface returns the MachineInterface associated with the given mac

func (*EtcdDataSource) MachineInterfaces added in v0.9.2

func (ds *EtcdDataSource) MachineInterfaces() ([]MachineInterface, error)

MachineInterfaces returns all the machines in the cluster, as a slice of MachineInterfaces

func (*EtcdDataSource) SelfInfo added in v0.9.2

func (ds *EtcdDataSource) SelfInfo() InstanceInfo

SelfInfo return InstanceInfo of this instance of blacksmith

func (*EtcdDataSource) SetClusterVariable added in v0.9.2

func (ds *EtcdDataSource) SetClusterVariable(key string, value string) error

SetClusterVariable sets a cluster variable inside etcd

func (*EtcdDataSource) Shutdown added in v0.9.2

func (ds *EtcdDataSource) Shutdown() error

Shutdown removes the instance key from the list of instances, used to gracefully shutdown the instance

func (*EtcdDataSource) WhileMaster added in v0.9.2

func (ds *EtcdDataSource) WhileMaster() error

WhileMaster makes a heartbeat and returns IsMaster()

func (*EtcdDataSource) WorkspacePath

func (ds *EtcdDataSource) WorkspacePath() string

WorkspacePath returns the path to the workspace

type File added in v0.9.2

type File struct {
	ID                   string `json:"id,omitempty"`
	Name                 string `json:"name"`
	FromInstance         string `json:"fromInstance"`
	Location             string `json:"location"`
	UploadedAt           int64  `json:"uploadedAt"` // unix timestamp
	Size                 int64  `json:"size"`
	LastModificationDate int64  `json:"lastModifiedDate"`
}

File describes a file located inside our workspace

type InstanceInfo added in v0.9.2

type InstanceInfo struct {
	IP               net.IP           `json:"ip"`
	Nic              net.HardwareAddr `json:"nic"`
	WebPort          int              `json:"webPort"`
	Version          string           `json:"version"`
	Commit           string           `json:"commit"`
	BuildTime        string           `json:"buildTime"`
	ServiceStartTime int64            `json:"serviceStartTime"`
}

InstanceInfo describes an active instance of blacksmith running on some machine

func (*InstanceInfo) String added in v0.9.2

func (ii *InstanceInfo) String() string

type Machine

type Machine struct {
	IP        net.IP      `json:"ip"`
	FirstSeen int64       `json:"first_seen"`
	Type      MachineType `json:"type"`
}

Machine details

type MachineInterface added in v0.9.2

type MachineInterface interface {
	// Mac returns the hardware address of the associated machine
	Mac() net.HardwareAddr

	// Hostname returns the mac address formatted as a string suitable for hostname
	Hostname() string

	// Machine returns the associated Machine
	// If the createIfNeed is true, and there is no machine associated to this
	// mac, the machine will be created and returned. If the assignedIP is empty,
	// the IP will be assigned automatically, otherwise the given will be used.
	// In this case, an error will be raised if the given IP is currently assigned
	// to another mac.
	// If createIfNeed == nil, the assignedIP will be ignored.
	Machine(createIfNeed bool, assignedIP net.IP) (Machine, error)

	// LastSeen returns the last time the machine has been seen
	LastSeen() (int64, error)

	// CheckIn updates the _last_seen field of the machine
	CheckIn()

	// ListVariables returns the list of all the flgas of a machine from Etcd
	ListVariables() (map[string]string, error)

	// GetVariable Gets a machine's variable, or the global if it was not
	// set for the machine
	GetVariable(key string) (string, error)

	// SetVariable sets the value of the specified key
	SetVariable(key string, value string) error

	// DeleteVariable erases the entry specified by key
	DeleteVariable(key string) error
}

MachineInterface provides the interface for querying/altering Machine entries in the datasource

type MachineType added in v0.9.2

type MachineType int16

MachineType distinguishes normal servers from static ones, and from the BMC inside those machines

const (
	// MTNormal is for the ethernet of a server machine attached to our private
	// network and its ip is provided by our DHCP
	MTNormal MachineType = 1
	// MTStatic is for the ethernet of a server machine attached to our private
	// network, but the IP address is forces. Currentl just the Blacksmith
	// instances are created in this manner.
	MTStatic MachineType = 2
	// MTBMC is for the baseboard management controller embedded on the
	// motherboard of the server machines
	MTBMC MachineType = 3
)

type NetworkConfiguration added in v0.9.2

type NetworkConfiguration struct {
	Netmask              net.IP                     `json:"netmask"`
	Router               net.IP                     `json:"router"`
	ClasslessRouteOption []ClasslessRouteOptionPart `json:"classlessRouteOption"`
}

NetworkConfiguration is used to configure clients through dhcp

func UnmarshalNetworkConfiguration added in v0.9.2

func UnmarshalNetworkConfiguration(netConfStr string) (*NetworkConfiguration, error)

UnmarshalNetworkConfiguration returns a pointer to a newly constructed NetworkConfiguration from the given string

Jump to

Keyboard shortcuts

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