services

package module
v0.0.0-...-58306fc Latest Latest
Warning

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

Go to latest
Published: May 20, 2020 License: Apache-2.0 Imports: 29 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultBootType string

DefaultBootType specifies what a server will default to if no config is found

Functions

func AddDeployment

func AddDeployment(rawDeployment []byte) error

AddDeployment - This function will add a new deployment to the deployment configuration

func DeleteDeploymentAddress

func DeleteDeploymentAddress(address string, rawDeployment []byte) error

DeleteDeploymentAddress - This function will delete a deployment based upon it's IP Address

func DeleteDeploymentMac

func DeleteDeploymentMac(macAddress string, rawDeployment []byte) error

DeleteDeploymentMac - This function will delete a deployment based upon it's mac Address

func FindDeploymentConfigFromMac

func FindDeploymentConfigFromMac(mac string) string

FindDeploymentConfigFromMac - this will return the deployment configuration, allowing the DHCP server to return the correct DHCP options

func HandleRead

func HandleRead(filename string) (r io.Reader, err error)

HandleRead : read a ROfs file and send over tftp

func HandleWrite

func HandleWrite(filename string) (w io.Writer, err error)

HandleWrite : writing is disabled in this service

func HealthCheckHandler

func HealthCheckHandler(w http.ResponseWriter, r *http.Request)

HealthCheckHandler -

func OpenISO

func OpenISO(isoPath, isoPrefix string) error

OpenISO will open an iso and add it to out ISO Map for reading at a later point

func ParseControllerData

func ParseControllerData(b []byte) error

ParseControllerData will read in a byte array and attempt to parse it as yaml or json

func RegisterToAPIServer

func RegisterToAPIServer()

RegisterToAPIServer - will add the endpoints to the API server

func UpdateDeployment

func UpdateDeployment(macAddress string, rawDeployment []byte) error

UpdateDeployment - This function will add a new deployment to the deployment configuration

func UpdateDeploymentConfig

func UpdateDeploymentConfig(rawDeploymentConfig []byte) error

UpdateDeploymentConfig will read a configuration string and build the iPXE files needed

func UpdateGlobalDeploymentConfig

func UpdateGlobalDeploymentConfig(rawDeployment []byte) error

UpdateGlobalDeploymentConfig - This allows updating of the global configuration independently

Types

type BootConfig

type BootConfig struct {
	ConfigName string `json:"configName"`
	ConfigType string `json:"configType"`

	// iPXE file settings - exported
	Kernel  string `json:"kernelPath"`
	Initrd  string `json:"initrdPath"`
	Cmdline string `json:"cmdline"`

	// ISO Reader settings
	ISOPath   string `json:"isoPath,omitempty"`
	ISOPrefix string `json:"isoPrefix,omitempty"`
}

BootConfig defines a named configuration for booting

func (*BootConfig) Parse

func (b *BootConfig) Parse() error

Parse will read through a new configuration and implement the configuration if possible

type BootController

type BootController struct {
	AdapterName *string `json:"adapter"` // A physical adapter to bind to e.g. en0, eth0

	// Servers
	EnableDHCP *bool `json:"enableDHCP"` // Enable Server
	//DHCP Configuration
	DHCPConfig dhcpConfig `json:"dhcpConfig,omitempty"`

	// TFTP / HTTP configuration
	EnableTFTP  *bool   `json:"enableTFTP"`  // Enable Server
	TFTPAddress *string `json:"addressTFTP"` // Should ideally be the IP of the adapter
	EnableHTTP  *bool   `json:"enableHTTP"`  // Enable Server
	HTTPAddress *string `json:"addressHTTP"` // Should ideally be the IP of the adapter

	// TFTP Configuration
	PXEFileName *string `json:"pxePath"` // undionly.kpxe

	// Boot Configuration
	BootConfigs []BootConfig `json:"bootConfigs"` // Array of kernel configurations
	// contains filtered or unexported fields
}

BootController contains the settings that define how the remote boot will

var Controller BootController

Controller contains all the "current" settings for booting servers

func (*BootController) DelUnLeased

func (c *BootController) DelUnLeased(mac string)

DelUnLeased - This will retrieve all of the un-allocated leases from the boot controller

func (*BootController) DeleteBootControllerConfig

func (c *BootController) DeleteBootControllerConfig(configName string) error

DeleteBootControllerConfig - will iterate through the boot controller and see if any changes need applying this is mainly for the dynamic loading of ISOs

func (*BootController) GetLeases

func (c *BootController) GetLeases() *[]Lease

GetLeases - This will retrieve all of the allocated leases from the boot controller

func (*BootController) GetUnLeased

func (c *BootController) GetUnLeased() *[]Lease

GetUnLeased - This will retrieve all of the un-allocated leases from the boot controller

func (*BootController) StartServices

func (c *BootController) StartServices(deployment []byte) error

StartServices - This will start all of the enabled services

type DHCPSettings

type DHCPSettings struct {
	IP      net.IP       // Server IP to use
	Options dhcp.Options // Options to send to DHCP Clients
	Start   net.IP       // Start of IP range to distribute

	LeaseRange    int           // Number of IPs to distribute (starting from start)
	LeaseDuration time.Duration // Lease period

	Leases   map[int]Lease // Map to keep track of leases
	UnLeased []Lease       // Map to keep track of unleased devices, and when they were seen
}

DHCPSettings -

func (*DHCPSettings) ServeDHCP

func (h *DHCPSettings) ServeDHCP(p dhcp.Packet, msgType dhcp.MessageType, options dhcp.Options) (d dhcp.Packet)

ServeDHCP - Is the function that is called when ever plunder recieves DHCP packets.

type DeploymentConfig

type DeploymentConfig struct {
	MAC        string     `json:"mac"`
	ConfigName string     `json:"bootConfigName,omitempty"` // To be discovered in the controller BootConfig array
	ConfigBoot BootConfig `json:"bootConfig,omitempty"`     // Array of kernel configurations
	ConfigHost HostConfig `json:"config"`
}

DeploymentConfig - is used to parse the files containing all server configurations

func GetDeployment

func GetDeployment(macAddress string) *DeploymentConfig

GetDeployment - This function will add a new deployment to the deployment configuration

type DeploymentConfigurationFile

type DeploymentConfigurationFile struct {
	GlobalServerConfig HostConfig         `json:"globalConfig"`
	Configs            []DeploymentConfig `json:"deployments"`
}

DeploymentConfigurationFile - The bootstraps.Configs is used by other packages to manage use case for Mac addresses

var Deployments DeploymentConfigurationFile

Deployments - contains an accessible "current" configuration for all deployments

func ParseDeployment

func ParseDeployment(b []byte) (*DeploymentConfigurationFile, error)

ParseDeployment will read in a byte array and attempt to parse it as yaml or json

type HostConfig

type HostConfig struct {

	// Not required for the global configuration
	Adapter    string `json:"adapter,omitempty"`  // Adapter to be configured with networking address
	IPAddress  string `json:"address,omitempty"`  // Allocated IP address for a host (ignored for global)
	ServerName string `json:"hostname,omitempty"` // Hostname to be applied to a server

	// Typically shared details
	Gateway    string `json:"gateway,omitempty"`    // Default Gateway
	Subnet     string `json:"subnet,omitempty"`     // Subnet to be used for the host
	NameServer string `json:"nameserver,omitempty"` // Set the default nameserver for DNS
	NTPServer  string `json:"ntpserver,omitempty"`  // Time Server to be used

	LVMEnable    *bool `json:"lvmEnabled,omitempty"`   // Use LVM for the configuration
	SwapDisabled *bool `json:"swapDisabled,omitempty"` // Dont create swap partitions

	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`

	// RepositoryAddress is required for pre-seed / kickstart
	RepositoryAddress string `json:"repoaddress,omitempty"`
	// MirrorDirectory is an Ubuntu specific config
	MirrorDirectory string `json:"mirrordir,omitempty"`

	// SSHKeyPath will typically be referenced from a file ~/.ssh/id_rsa.pub
	SSHKeyPath string `json:"sshkeypath,omitempty"`
	// SSHKey is a full SSH Key in base 64
	SSHKey string `json:"sshkey,omitempty"`

	// Packages to be installed
	Packages string `json:"packages,omitempty"`

	// OS Image provisioning
	BOOTYAction string `json:"bootyAction,omitempty"`
	Compressed  *bool  `json:"compressed,omitempty"`

	// Write image to disk from remote address
	SourceImage       string `json:"sourceImage,omitempty"`
	DestinationDevice string `json:"destinationDevice,omitempty"`

	// Read image from disk from remote address
	SourceDevice       string `json:"sourceDevice,omitempty"`
	DestinationAddress string `json:"destinationAddress,omitempty"`

	// Volume modifications (LVM2)
	GrowPartition *int   `json:"growPartition,omitempty"`
	LVMRootName   string `json:"lvmRootName,omitempty"`

	// Troubleshooting
	ShellOnFail *bool `json:"shellOnFail,omitempty"`
}

HostConfig - Defines how a server will be configured by plunder

func (*HostConfig) BuildBOOTYconfig

func (config *HostConfig) BuildBOOTYconfig() string

BuildBOOTYconfig - Creates a new presseed configuration using the passed data

func (*HostConfig) BuildESXiConfig

func (config *HostConfig) BuildESXiConfig() string

BuildESXiConfig - Creates a new presseed configuration using the passed data

func (*HostConfig) BuildESXiKickStart

func (config *HostConfig) BuildESXiKickStart() string

BuildESXiKickStart - Creates a new presseed configuration using the passed data

func (*HostConfig) BuildKickStartConfig

func (config *HostConfig) BuildKickStartConfig() string

BuildKickStartConfig - Creates a new presseed configuration using the passed data

func (*HostConfig) BuildPreeSeedConfig

func (config *HostConfig) BuildPreeSeedConfig() string

BuildPreeSeedConfig - Creates a new presseed configuration using the passed data

func (*HostConfig) PopulateFromGlobalConfiguration

func (c *HostConfig) PopulateFromGlobalConfiguration(globalConfig HostConfig)

PopulateFromGlobalConfiguration - This will read a deployment configuration and attempt to fill any missing fields from the global config

func (*HostConfig) ReadKeyFromFile

func (c *HostConfig) ReadKeyFromFile() (string, error)

ReadKeyFromFile - will attempt to read an sshkey from a file and populate the struct

type Lease

type Lease struct {
	MAC    string    `json:"mac"`  // Client's Physical Address
	Expiry time.Time `json:"time"` // When the lease expires
}

Lease defines a lease that is allocated to a client

type WriteCounter

type WriteCounter struct {
	Total uint64
}

WriteCounter counts the number of bytes written to it. It implements to the io.Writer interface and we can pass this into io.TeeReader() which will report progress on each write cycle.

func (*WriteCounter) Write

func (wc *WriteCounter) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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