drbd

package
v0.0.0-...-20c3210 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	KeyResource       = "resource "
	KeyConnectionMesh = "connection-mesh "
	KeyHosts          = "hosts "
	KeyOn             = "on "
	KeyNodeID         = "node-id "
	KeyDevice         = "device "
	KeyDisk           = "disk "
	KeyMetaDisk       = "meta-disk "
	KeyAddress        = "address "
	KeyVolume         = "volume "

	KeyResourceLen       = len(KeyResource)
	KeyConnectionMeshLen = len(KeyConnectionMesh)
	KeyHostsLen          = len(KeyHosts)
	KeyOnLen             = len(KeyOn)
	KeyNodeIDLen         = len(KeyNodeID)
	KeyDeviceLen         = len(KeyDevice)
	KeyDiskLen           = len(KeyDisk)
	KeyMetaDiskLen       = len(KeyMetaDisk)
	KeyAddressLen        = len(KeyAddress)
	KeyVolumeLen         = len(KeyVolume)

	RetryDelay   = time.Second * 1
	RetryTimeout = time.Second * 10

	ExitCodeDeviceInUse = 11

	MaxDRBD = 512
	MinPort = 7289
	MaxPort = 7489
)

Functions

func Dump

func Dump() ([]byte, error)

func IsCapable

func IsCapable() bool

func ResConfigFile

func ResConfigFile(res string) string

func Version

func Version() (string, error)

func WithLogger

func WithLogger(log *plog.Logger) funcopt.O

Types

type Config

type Config struct {
	XMLName   xml.Name         `xml:"config"`
	File      string           `xml:"config,attr"`
	Common    ConfigCommon     `xml:"common"`
	Resources []ConfigResource `xml:"resource"`
}

func GetConfig

func GetConfig() (*Config, error)

func ParseConfig

func ParseConfig(b []byte) (*Config, error)

func (Config) GetMinors

func (t Config) GetMinors() map[string]any

func (Config) GetPorts

func (t Config) GetPorts() map[string]any

func (Config) GetResource

func (t Config) GetResource(name string) (ConfigResource, bool)

type ConfigAddress

type ConfigAddress struct {
	XMLName xml.Name `xml:"address"`
	Family  string   `xml:"family,attr"`
	Port    string   `xml:"port,attr"`
	IP      string   `xml:",chardata"`
}

type ConfigCommon

type ConfigCommon struct {
	XMLName xml.Name `xml:"common"`
}

type ConfigConnection

type ConfigConnection struct {
	XMLName xml.Name               `xml:"connection"`
	Hosts   []ConfigConnectionHost `xml:"host"`
}

type ConfigConnectionHost

type ConfigConnectionHost struct {
	XMLName xml.Name      `xml:"host"`
	Name    string        `xml:"name,attr"`
	Address ConfigAddress `xml:"address"`
}

type ConfigDevice

type ConfigDevice struct {
	Path  string `xml:",chardata"`
	Minor string `xml:"minor,attr"`
}

type ConfigHost

type ConfigHost struct {
	Name    string         `xml:"name,attr"`
	Volumes []ConfigVolume `xml:"volume"`
	Address ConfigAddress  `xml:"address"`
}

func (ConfigHost) GetVolume

func (t ConfigHost) GetVolume(name string) (ConfigVolume, bool)

type ConfigResource

type ConfigResource struct {
	XMLName    xml.Name         `xml:"resource"`
	Name       string           `xml:"name,attr"`
	FileLine   string           `xml:"conf-file-line"`
	Hosts      []ConfigHost     `xml:"host"`
	Connection ConfigConnection `xml:"connection"`
}

func (ConfigResource) GetHost

func (t ConfigResource) GetHost(name string) (ConfigHost, bool)

type ConfigVolume

type ConfigVolume struct {
	Name     string       `xml:"vnr,attr"`
	Device   ConfigDevice `xml:"device"`
	Disk     string       `xml:"disk"`
	MetaDisk string       `xml:"meta-disk"`
}

type Digest

type Digest struct {
	Ports  map[string]any
	Minors map[string]any
}

func GetDigest

func GetDigest() (Digest, error)

func ParseDigest

func ParseDigest(b []byte) (Digest, error)

func (Digest) FreeMinor

func (t Digest) FreeMinor(exclude []int) (int, error)

func (Digest) FreePort

func (t Digest) FreePort(exclude []int) (int, error)

type T

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

func New

func New(res string, opts ...funcopt.O) *T

func (T) Adjust

func (t T) Adjust() error

func (T) Attach

func (t T) Attach() error

func (T) ConnState

func (t T) ConnState() (string, error)

func (T) Connect

func (t T) Connect() error

func (*T) Create

func (t *T) Create(disk string, addr string, port int) error

func (T) CreateMD

func (t T) CreateMD(maxPeers int) error

func (T) DetachForce

func (t T) DetachForce() error

func (T) Disconnect

func (t T) Disconnect() error

func (T) DiskStates

func (t T) DiskStates() ([]string, error)

func (T) Down

func (t T) Down() error

func (T) HasMD

func (t T) HasMD() (bool, error)

func (T) IsDefined

func (t T) IsDefined() (bool, error)

func (T) IsUp

func (t T) IsUp() (bool, string, error)

func (T) ModProbe

func (t T) ModProbe() error

func (T) Primary

func (t T) Primary() error

func (T) PrimaryForce

func (t T) PrimaryForce() error

func (T) Remove

func (t T) Remove() error

func (T) Role

func (t T) Role() (string, error)

func (T) Secondary

func (t T) Secondary() error

func (T) Up

func (t T) Up() error

func (T) WipeMD

func (t T) WipeMD() error

WipeMD executes the `wipe-md` drbd command.

Ignore the exit code `20`:

Returned when the sub dev is not found.
No need to fail, as the sub dev is surely flagged for unprovision too,
which will wipe metadata.
This situation happens on unprovision on a stopped instance, when drbd
is stacked over another (stopped) disk resource.

Jump to

Keyboard shortcuts

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