datasource

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2016 License: GPL-2.0 Imports: 16 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
	MasterTtlTime           = ActiveMasterUpdateTime * 3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BlacksmithVersion

type BlacksmithVersion struct {
	Version   string `json:"version"`
	Commit    string `json:"commit"`
	BuildTime string `json:"buildTime"`
}

type DataSource

type DataSource interface {
	Version() BlacksmithVersion

	// CoreOSVerison returns the coreOs version that blacksmith supplies
	CoreOSVersion() (string, error)

	// GetMachine returns The Machine object with the specified Hardware
	// address. Returns a flag to specify whether or not the entry exists
	GetMachine(net.HardwareAddr) (Machine, bool)

	// CreateMachine creates a machine with the specified hardware address and IP
	// the second return value will be set to true in case of successful machine
	// creation and to false in case of duplicate hardware address or IP
	CreateMachine(net.HardwareAddr, net.IP) (Machine, bool)

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

	// Machines returns a slice of Machines whose entries are present in the
	// datasource storage
	Machines() ([]Machine, error)

	// Get returns value associated with key
	Get(key string) (string, error)

	// Set sets key equal to value.
	Set(key, value string) error

	// Delete erases a key from the datasource
	Delete(key string) error

	// Gets a key, returns it's value and deletes it
	GetAndDelete(key string) (string, error)

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

	// LeaseStart specifies dhcp pool starting ip
	LeaseStart() net.IP
	// LeaseRange specifies number of IPs the dhcp server can assign
	LeaseRange() int

	// Assign finds an IP for the specified nic
	Assign(nic string) (net.IP, error)

	// Request is how to client requests to use the Ip address
	Request(nic string, currentIP net.IP) (net.IP, error)

	// DNSAddresses returns addresses of the dns servers present in the network which
	// can answer "what is the ip address of nodeX ?"
	// a byte slice is returned to be used as option 6 (rfc2132) in a dhcp Request
	// reply packet
	DNSAddresses() ([]byte, error)

	IsMaster() bool
	RemoveInstance() error
}

GeneralDataSource provides the interface for querying general information

func NewEtcdDataSource

func NewEtcdDataSource(kapi etcd.KeysAPI, client etcd.Client, leaseStart net.IP,
	leaseRange int, clusterName, workspacePath string, serverIP net.IP,
	defaultNameServers []string, version BlacksmithVersion) (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) Assign

func (ds *EtcdDataSource) Assign(nic string) (net.IP, error)

Assign assigns an ip to the node with the specified nic Will use etcd machines records as LeasePool part of DHCPDataSource interface implementation

func (*EtcdDataSource) ClusterName

func (ds *EtcdDataSource) ClusterName() string

ClusterName returns the name of the cluster

func (*EtcdDataSource) CoreOSVersion

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

CoreOSVersion gets the current value from etcd and returns it if the image folder exists if not, the inital CoreOS version will be returned, with the raised error part of GeneralDataSource interface implementation

func (*EtcdDataSource) CreateMachine

func (ds *EtcdDataSource) CreateMachine(mac net.HardwareAddr, ip net.IP) (Machine, bool)

CreateMachine Creates a machine, returns the handle, and writes directories and flags to etcd Second return value determines whether or not Machine creation has been successful part of GeneralDataSource interface implementation

func (*EtcdDataSource) DNSAddresses

func (ds *EtcdDataSource) DNSAddresses() ([]byte, error)

DNSAddresses returns the ip addresses of the present skydns servers in the network, marshalled as specified in rfc2132 (option 6) part of DHCPDataSource ineterface implementation

func (*EtcdDataSource) Delete

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

Delete erases the key from etcd part of GeneralDataSource interface implementation

func (*EtcdDataSource) Get

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

Get parses the etcd key and returns it's value part of GeneralDataSource interface implementation

func (*EtcdDataSource) GetAndDelete

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

GetAndDelete gets the value of an etcd key and returns it, and deletes the record afterwards part of GeneralDataSource interface implementation

func (*EtcdDataSource) GetMachine

func (ds *EtcdDataSource) GetMachine(mac net.HardwareAddr) (Machine, bool)

GetMachine returns a Machine interface which is the accessor/getter/setter for a node in the etcd datasource. If an entry associated with the passed mac address does not exist the second return value will be set to false part of GeneralDataSource interface implementation

func (*EtcdDataSource) IsMaster

func (ds *EtcdDataSource) IsMaster() bool

IsMaster checks for being master, and makes a heartbeat

func (*EtcdDataSource) LeaseRange

func (ds *EtcdDataSource) LeaseRange() int

LeaseRange returns the IP range from which IP addresses are assignable to clients by the DHCP server part of DHCPDataSource interface implementation

func (*EtcdDataSource) LeaseStart

func (ds *EtcdDataSource) LeaseStart() net.IP

LeaseStart returns the first IP address that the DHCP server can offer to a DHCP client part of DHCPDataSource interface implementation

func (*EtcdDataSource) Machines

func (ds *EtcdDataSource) Machines() ([]Machine, error)

Machines returns an array of the recognized machines in etcd datasource part of GeneralDataSource interface implementation

func (*EtcdDataSource) RemoveInstance

func (ds *EtcdDataSource) RemoveInstance() error

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

func (*EtcdDataSource) Request

func (ds *EtcdDataSource) Request(nic string, currentIP net.IP) (net.IP, error)

Request answers a dhcp request Uses etcd as backend part of DHCPDataSource interface implementation

func (*EtcdDataSource) Set

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

Set sets and etcd key to a value part of GeneralDataSource interface implementation

func (*EtcdDataSource) Version

func (ds *EtcdDataSource) Version() BlacksmithVersion

Version is returns the version details of the current blacksmith instance part of the GeneralDataSource interface implementation

func (*EtcdDataSource) WorkspacePath

func (ds *EtcdDataSource) WorkspacePath() string

WorkspacePath returns the path to the workspace part of the GeneralDataSource interface implementation

type EtcdMachine

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

EtcdMachine implements datasource.Machine interface using etcd as it's datasource

func (*EtcdMachine) CheckIn

func (m *EtcdMachine) CheckIn()

CheckIn updates the _last_seen entry of this machine in etcd part of EtcdMachine interface implementation

func (*EtcdMachine) DeleteFlag

func (m *EtcdMachine) DeleteFlag(key string) error

DeleteFlag deletes the record associated with key from Etcd part of Machine interface implementation

func (*EtcdMachine) Domain

func (m *EtcdMachine) Domain() string

Domain returns this machine's domain which is equal to the cluster name

func (*EtcdMachine) FirstSeen

func (m *EtcdMachine) FirstSeen() (time.Time, error)

FirstSeen returns the time upon which that the machine has been first seen queries etcd part of Machine interface implementaiton

func (*EtcdMachine) GetAndDeleteFlag

func (m *EtcdMachine) GetAndDeleteFlag(key string) (string, error)

GetAndDeleteFlag doesn't do an awful lot of magic. just combines GetFlag and DeleteFlag operations part of Machine interface implementation

func (*EtcdMachine) GetFlag

func (m *EtcdMachine) GetFlag(key string) (string, error)

GetFlag Gets a machine's flag from Etcd etcd and machine prefix will be added to the path part of Machine interface implementation

func (*EtcdMachine) IP

func (m *EtcdMachine) IP() (net.IP, error)

IP Returns this machine's IP queries etcd part of Machine interface implementation

func (*EtcdMachine) LastSeen

func (m *EtcdMachine) LastSeen() (time.Time, error)

LastSeen returns the last time the machine has been ??? part of Machine interface implementation

func (*EtcdMachine) ListFlags

func (m *EtcdMachine) ListFlags() (map[string]string, error)

ListFlags returns the list of all the flgas of a machine from Etcd etcd and machine prefix will be added to the path part of Machine interface implementation

func (*EtcdMachine) Mac

func (m *EtcdMachine) Mac() net.HardwareAddr

Mac Returns this machine's hardware address part of Machine interface implementation

func (*EtcdMachine) Name

func (m *EtcdMachine) Name() string

Name returns this machine's hostname

func (*EtcdMachine) SetFlag

func (m *EtcdMachine) SetFlag(key, value string) error

SetFlag Sets a machin'es flag in Etcd etcd and machine prefix will be added to the PathPrefix part of Machine interface implementation

type Machine

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

	// IP reutrns the IP address associated with the machine
	IP() (net.IP, error)

	// Name returns the hostname of the machine
	Name() string

	// Domain returns the domain name of the machine
	Domain() string

	// FirstSeen returns the time upon which the machine has
	// been seen
	FirstSeen() (time.Time, error)

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

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

	// GetFlag returns the value of the supplied key
	GetFlag(key string) (string, error)

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

	// GetAndDeleteFlag gets the value associated with the key
	// and erases it afterwards
	GetAndDeleteFlag(key string) (string, error)

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

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

Jump to

Keyboard shortcuts

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