provision: github.com/digitalrebar/provision/midlayer Index | Files

package midlayer

import "github.com/digitalrebar/provision/midlayer"

midlayer contains the DHCP server code for DigitalRebar Provision. It has the responsibility for providing the actual data manipulate for the DHCP Protocol.

Index

Package Files

abp.go actions.go controller.go dhcp.go dhcpUtil.go doc.go ha.go messaging.go messaging_client.go messaging_server.go metrics.go plugin.go pxe.go static.go tftp.go

Constants

const (
    PLUGIN_CREATED     int = 1
    PLUGIN_STARTED     int = 2
    PLUGIN_CONFIGED    int = 3
    PLUGIN_STOPPED     int = 4
    PLUGIN_REMOVED     int = 5
    PLUGIN_CONFIGURING int = 6
    PLUGIN_SHOULD_STOP int = 7
)

func AddIP Uses

func AddIP(ip, iface string) error

func MacStrategy Uses

func MacStrategy(p dhcp.Packet, options dhcp.Options) string

func OsUdpProtoCheck Uses

func OsUdpProtoCheck() string

func RemoveIP Uses

func RemoveIP(ip, iface string) error

func ReverseProxy Uses

func ReverseProxy(pc *PluginController) gin.HandlerFunc

func ServeMetrics Uses

func ServeMetrics(listenAt string, logger logger.Logger) (*http.Server, error)

func ServeStatic Uses

func ServeStatic(listenAt string, responder http.Handler, logger logger.Logger, pubs *backend.Publishers) (*http.Server, error)

type Actions Uses

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

func NewActions Uses

func NewActions() *Actions

func (*Actions) Add Uses

func (ma *Actions) Add(model_aa models.AvailableAction, plugin *RunningPlugin) error

func (*Actions) Get Uses

func (ma *Actions) Get(ob, name string) (AvailableActions, bool)

func (*Actions) GetSpecific Uses

func (ma *Actions) GetSpecific(ob, name, plugin string) (*AvailableAction, bool)

func (*Actions) List Uses

func (ma *Actions) List(ob string) []AvailableActions

func (*Actions) Remove Uses

func (ma *Actions) Remove(aa models.AvailableAction, plugin *RunningPlugin) error

func (*Actions) Run Uses

func (ma *Actions) Run(rt *backend.RequestTracker, ob string, maa *models.Action) (interface{}, error)

type AvailableAction Uses

type AvailableAction struct {
    models.AvailableAction

    Plugin *RunningPlugin
    // contains filtered or unexported fields
}

func (*AvailableAction) Release Uses

func (aa *AvailableAction) Release()

func (*AvailableAction) Reserve Uses

func (aa *AvailableAction) Reserve() error

func (*AvailableAction) Unload Uses

func (aa *AvailableAction) Unload()

type AvailableActions Uses

type AvailableActions []*AvailableAction

type BsdpBootOptions Uses

type BsdpBootOptions []*bsdpBootOption

func (BsdpBootOptions) ToOptions Uses

func (bos BsdpBootOptions) ToOptions(budget int) []byte

type ConsulClient Uses

type ConsulClient struct {
    Client *consul.Client
    // contains filtered or unexported fields
}

func (*ConsulClient) AquireSessionKey Uses

func (cc *ConsulClient) AquireSessionKey(key string, session string) (bool, error)

func (*ConsulClient) GetAgentName Uses

func (cc *ConsulClient) GetAgentName() string

func (*ConsulClient) GetKey Uses

func (cc *ConsulClient) GetKey(keyName string) (*consul.KVPair, error)

func (*ConsulClient) GetSession Uses

func (cc *ConsulClient) GetSession(sessionName string) string

func (*ConsulClient) ReleaseKey Uses

func (cc *ConsulClient) ReleaseKey(key *consul.KVPair) (bool, error)

type DhcpHandler Uses

type DhcpHandler struct {
    logger.Logger
    // contains filtered or unexported fields
}

DhcpHandler is responsible for listening to incoming DHCP packets, building a DhcpRequest for each one, then kicking that reqest off to handle the packet.

func (*DhcpHandler) NewRequest Uses

func (h *DhcpHandler) NewRequest(buf []byte, cm *ipv4.ControlMessage, srcAddr net.Addr, start time.Time) *DhcpRequest

func (*DhcpHandler) Serve Uses

func (h *DhcpHandler) Serve() error

func (*DhcpHandler) Shutdown Uses

func (h *DhcpHandler) Shutdown(ctx context.Context) error

type DhcpMetrics Uses

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

func NewDhcpMetrics Uses

func NewDhcpMetrics(l logger.Logger, binlOnly bool) *DhcpMetrics

func (*DhcpMetrics) CountPacket Uses

func (dm *DhcpMetrics) CountPacket(count, elapsed float64, res dhcp.Packet, reqType, resType string)

type DhcpRequest Uses

type DhcpRequest struct {
    logger.Logger
    // contains filtered or unexported fields
}

DhcpRequest records all the information needed to handle a single in-flight DHCP request. One of these is created for every incoming DHCP packet.

func (*DhcpRequest) FakeLease Uses

func (dhr *DhcpRequest) FakeLease(req net.IP) *backend.Lease

FakeLease is a helper function for fetching a fake lease from the backend. We use fake leases when handling ProxyDHCP and binl requests, as we don't actually want to allocate an IP address or anything crazy like that.

func (*DhcpRequest) MarshalText Uses

func (dhr *DhcpRequest) MarshalText() ([]byte, error)

func (*DhcpRequest) PrintIncoming Uses

func (dhr *DhcpRequest) PrintIncoming() string

func (*DhcpRequest) PrintOutgoing Uses

func (dhr *DhcpRequest) PrintOutgoing(p dhcp.Packet) string

func (*DhcpRequest) Process Uses

func (dhr *DhcpRequest) Process() (string, string)

Process is responsible for checking basic sanity of an incoming DHCP packet, handing it off to ServeDHCP or ServeBinl, and performing some common post-processing if we have an outgoing packet to send.

func (*DhcpRequest) Reply Uses

func (dhr *DhcpRequest) Reply(p dhcp.Packet)

func (*DhcpRequest) Request Uses

func (dhr *DhcpRequest) Request(locks ...string) *backend.RequestTracker

Request is a shorthand function for creating a RequestTracker to interact with the backend.

func (*DhcpRequest) Run Uses

func (dhr *DhcpRequest) Run(count int)

Run processes an incoming DhcpRequest and sends the resulting packet (if any) back out over the same interface it came in on.

func (*DhcpRequest) ServeAppleBSDP Uses

func (dhr *DhcpRequest) ServeAppleBSDP() string

func (*DhcpRequest) ServeBinl Uses

func (dhr *DhcpRequest) ServeBinl() string

ServeBinl is responsible for handling ProxyDHCP Request messages and binl Discover messages. Both of those come in on port 4011.

func (*DhcpRequest) ServeDHCP Uses

func (dhr *DhcpRequest) ServeDHCP() string

ServeDHCP is responsible for handling regular DHCP traffic as well as ProxyDHCP DISCOVER messages -- essentially everything that comes in on port 67.

func (*DhcpRequest) Strategy Uses

func (dhr *DhcpRequest) Strategy(name string) StrategyFunc

func (*DhcpRequest) UnmarshalText Uses

func (dhr *DhcpRequest) UnmarshalText(buf []byte) error

type LeaderElection Uses

type LeaderElection struct {
    LeaderKey     string
    WatchWaitTime int
    StopElection  chan bool
    Client        *ConsulClient
    // contains filtered or unexported fields
}

func BecomeLeader Uses

func BecomeLeader(l *log.Logger) *LeaderElection

func (*LeaderElection) ElectLeader Uses

func (le *LeaderElection) ElectLeader(wakeme chan bool)

func (*LeaderElection) GetSession Uses

func (le *LeaderElection) GetSession(sessionName string) string

func (*LeaderElection) IsLeader Uses

func (le *LeaderElection) IsLeader() bool

func (*LeaderElection) Shutdown Uses

func (le *LeaderElection) Shutdown(ctx context.Context) error

func (*LeaderElection) StepDown Uses

func (le *LeaderElection) StepDown() error

type ObjectCommands Uses

type ObjectCommands map[string]AvailableActions

type ObjectsCommands Uses

type ObjectsCommands map[string]ObjectCommands

type PluginClient Uses

type PluginClient struct {
    logger.Logger
    // contains filtered or unexported fields
}

func NewPluginClient Uses

func NewPluginClient(pc *PluginController, pluginCommDir, plugin, provider string, l logger.Logger, apiURL, staticURL, token, path string) (answer *PluginClient, theErr error)

func (*PluginClient) Action Uses

func (pc *PluginClient) Action(rt *backend.RequestTracker, a *models.Action) (interface{}, error)

func (*PluginClient) Config Uses

func (pc *PluginClient) Config(params map[string]interface{}) error

func (*PluginClient) Publish Uses

func (pc *PluginClient) Publish(e *models.Event) error

func (*PluginClient) Release Uses

func (pc *PluginClient) Release()

func (*PluginClient) Reserve Uses

func (pc *PluginClient) Reserve() error

func (*PluginClient) Stop Uses

func (pc *PluginClient) Stop() error

func (*PluginClient) Unload Uses

func (pc *PluginClient) Unload()

type PluginController Uses

type PluginController struct {
    logger.Logger

    AvailableProviders map[string]*models.PluginProvider

    Actions        *Actions
    AddStorageType func(string)
    // contains filtered or unexported fields
}

func InitPluginController Uses

func InitPluginController(pluginDir, pluginCommDir string, dt *backend.DataTracker, pubs *backend.Publishers) (pc *PluginController, err error)

* Create contoller and start an event listener.

func (*PluginController) GetPluginProvider Uses

func (pc *PluginController) GetPluginProvider(name string) *models.PluginProvider

func (*PluginController) GetPluginProviders Uses

func (pc *PluginController) GetPluginProviders() []*models.PluginProvider

func (*PluginController) Publish Uses

func (pc *PluginController) Publish(e *models.Event) error

func (*PluginController) Release Uses

func (pc *PluginController) Release()

func (*PluginController) RemovePluginProvider Uses

func (pc *PluginController) RemovePluginProvider(name string) error

func (*PluginController) Request Uses

func (pc *PluginController) Request(locks ...string) *backend.RequestTracker

func (*PluginController) Reserve Uses

func (pc *PluginController) Reserve() error

This never gets unloaded.

func (*PluginController) Shutdown Uses

func (pc *PluginController) Shutdown(ctx context.Context) error

func (*PluginController) StartController Uses

func (pc *PluginController) StartController() error

func (*PluginController) StartPlugins Uses

func (pc *PluginController) StartPlugins()

func (*PluginController) StartRouter Uses

func (pc *PluginController) StartRouter(apiGroup *gin.RouterGroup)

func (*PluginController) Unload Uses

func (pc *PluginController) Unload()

func (*PluginController) UploadPluginProvider Uses

func (pc *PluginController) UploadPluginProvider(c *gin.Context, fileRoot, name string) (*models.PluginProviderUploadInfo, *models.Error)

type RunningPlugin Uses

type RunningPlugin struct {
    Plugin   *models.Plugin
    Provider *models.PluginProvider
    Client   *PluginClient
    // contains filtered or unexported fields
}

type Service Uses

type Service interface {
    Shutdown(context.Context) error
}

func ServeTftp Uses

func ServeTftp(listen string, responder func(string, net.IP) (io.Reader, error),
    log logger.Logger, pubs *backend.Publishers) (Service, error)

func StartDhcpHandler Uses

func StartDhcpHandler(dhcpInfo *backend.DataTracker,
    log logger.Logger,
    dhcpIfs string,
    dhcpPort int,
    pubs *backend.Publishers,
    proxyOnly bool,
    fakePinger bool) (Service, error)

type Strategy Uses

type Strategy struct {
    Name     string
    GenToken StrategyFunc
}

type StrategyFunc Uses

type StrategyFunc func(p dhcp.Packet, options dhcp.Options) string

type TftpHandler Uses

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

func (*TftpHandler) Shutdown Uses

func (h *TftpHandler) Shutdown(ctx context.Context) error

Package midlayer imports 38 packages (graph) and is imported by 2 packages. Updated 2018-12-18. Refresh now. Tools for package owners.