godrbdutils

package module
v0.0.0-...-ec7ed42 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2019 License: Apache-2.0 Imports: 10 Imported by: 3

README

godrbdutils

Golang library for drbdadm/drbdsetup. For now don't expect the API to be stable in any way.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNumber

func GetNumber(min, max int, used []int) (int, error)

GetNumber is used to return a free number within [min,max], where both are >=0 It can be used to allocate new Port/Minor numbers

Types

type Action

type Action int
const (
	Up Action = iota
	Down
	Adjust
	Attach
	Detach
	Connect
	Disconnect
	Primary
	Secondary
	Create_md
)

func (Action) String

func (i Action) String() string

type Cmd

type Cmd int
const (
	Drbdsetup Cmd = iota
	Drbdadm
)

func (Cmd) String

func (i Cmd) String() string

type DrbdAdm

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

func NewDrbdAdm

func NewDrbdAdm(res []string) *DrbdAdm

func (*DrbdAdm) Adjust

func (a *DrbdAdm) Adjust(arg ...string) ([]byte, error)

func (*DrbdAdm) Attach

func (a *DrbdAdm) Attach(arg ...string) ([]byte, error)

func (*DrbdAdm) Connect

func (a *DrbdAdm) Connect(arg ...string) ([]byte, error)

func (*DrbdAdm) CreateMetaData

func (a *DrbdAdm) CreateMetaData(arg ...string) ([]byte, error)

func (*DrbdAdm) Detach

func (a *DrbdAdm) Detach(arg ...string) ([]byte, error)

func (*DrbdAdm) Disconnect

func (a *DrbdAdm) Disconnect(arg ...string) ([]byte, error)

func (*DrbdAdm) Down

func (a *DrbdAdm) Down(arg ...string) ([]byte, error)

func (*DrbdAdm) Primary

func (a *DrbdAdm) Primary(arg ...string) ([]byte, error)

func (*DrbdAdm) Secondary

func (a *DrbdAdm) Secondary(arg ...string) ([]byte, error)

func (*DrbdAdm) SetTimeout

func (a *DrbdAdm) SetTimeout(timeout time.Duration)

func (*DrbdAdm) Up

func (a *DrbdAdm) Up(arg ...string) ([]byte, error)

type DrbdCmd

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

func NewDrbdCmd

func NewDrbdCmd(cmd Cmd, action Action, res []string, arg ...string) (*DrbdCmd, error)

func (*DrbdCmd) CombinedOutput

func (c *DrbdCmd) CombinedOutput() ([]byte, error)

func (*DrbdCmd) SetTimeout

func (c *DrbdCmd) SetTimeout(timeout time.Duration)

func (*DrbdCmd) String

func (c *DrbdCmd) String() string

type Host

type Host struct {
	ID   int    `yaml:"Node-ID,omitempty"`
	Name string `yaml:"Hostname,omitempty"`
	IP   string `yaml:"IP,omitempty"`
	// contains filtered or unexported fields
}

type NumberPool

type NumberPool struct {
	sync.Mutex
	// contains filtered or unexported fields
}

NumberPool is used as a stateful type to keep track of used numbers

func NewNumberPool

func NewNumberPool(min, max int, used []int) *NumberPool

NewNumberPool is used to allacte a new number pool

func (*NumberPool) Get

func (n *NumberPool) Get() (int, error)

Get is used to get a free number

type Resource

type Resource struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Resource is a DRBD resource

func NewResource

func NewResource(name string, port int) *Resource

NewResource returns a new DRBD resource object

func (*Resource) AddHost

func (r *Resource) AddHost(id int, hostname, ip string) error

AddHost adds a host information to a resource

func (*Resource) AddVolume

func (r *Resource) AddVolume(id, minor int, backingDevice, hostname string) error

AddVolume adds DRBD volume information to a resource

func (*Resource) WriteConfig

func (r *Resource) WriteConfig(filename string) error

WriteConfig writes the configuration of a DRBD resource to file parsable by drbd-utils It is up to the user to check for errors and to check if the file is valid (and to remove it if it isn't).

Jump to

Keyboard shortcuts

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