cib

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2020 License: Apache-2.0 Imports: 11 Imported by: 3

Documentation

Index

Constants

View Source
const (
	JoinDown    joinState = "down"
	JoinPending joinState = "pending"
	JoinMember  joinState = "member"
	JoinBanned  joinState = "banned"
)

Variables

View Source
var (
	ErrCibFailed = errors.New("Failed to read the CRM configuration")
)

Functions

func GetNvPairValue

func GetNvPairValue(elem *xmltree.Element, name string) (*xmltree.Attr, error)

Types

type CIB

type CIB struct {
	Doc *xmltree.Document
}

func (*CIB) CreateResource

func (c *CIB) CreateResource(xml string) error

func (*CIB) DissolveConstraints

func (c *CIB) DissolveConstraints(delItems []string)

Removes CRM constraints that refer to the specified delItems names from the CIB XML document tree

func (*CIB) FindLrmState

func (c *CIB) FindLrmState(id string) LrmRunState

func (*CIB) FindNodeState added in v0.1.1

func (c *CIB) FindNodeState(uname string) (NodeState, error)

func (*CIB) FindResource

func (c *CIB) FindResource(id string) *xmltree.Element

func (*CIB) GetClusterName added in v0.1.5

func (c *CIB) GetClusterName() (string, error)

func (*CIB) GetNodeID added in v0.1.5

func (c *CIB) GetNodeID(uname string) (int, error)

func (*CIB) GetNodeOfResource added in v0.1.4

func (c *CIB) GetNodeOfResource(resource string) string

GetNodeOfResource finds the node on which a resource is currently running. For this, it looks at the node_state element in a hierarchy like this:

<cib>
  <status>
    <node_state>
      <lrm>
        <lrm_resources>
          <lrm_resource> ... </lrm_resource>
        </lrm_resources>
      </lrm>
    </node_state>
  </status>
</cib>

It will try to find an <lrm_resource> with an 'id' attribute corresponding to the resource name in question. If this is not found, an empty string is returned, signalling that the resource is not configured or not running on any node.

If the corresponding lrm_resource element is found, its run state is examined (see the updateRunState function). If the run state is found to be "Running", the name of the current node is returned.

func (*CIB) GetStonithEnabled added in v0.1.5

func (c *CIB) GetStonithEnabled() (bool, error)

func (*CIB) IsStandbyNode added in v0.1.4

func (c *CIB) IsStandbyNode(nodeUname string) (bool, error)

IsStandbyNode check if a node is currently set standby

func (*CIB) ListNodes added in v0.1.3

func (c *CIB) ListNodes() ([]Node, error)

func (*CIB) ListResourcesOnNode added in v0.1.6

func (c *CIB) ListResourcesOnNode(node string) ([]string, error)

ListResourcesOnNode lists all resources currently running on the given node

func (*CIB) ReadConfiguration

func (c *CIB) ReadConfiguration() error

ReadConfiguration calls the crm list command and parses the XML data it returns.

func (*CIB) SetClusterName added in v0.1.5

func (c *CIB) SetClusterName(value string) error

func (*CIB) SetStonithEnabled

func (c *CIB) SetStonithEnabled(value bool) error

func (*CIB) StandbyNode added in v0.1.3

func (c *CIB) StandbyNode(nodeUname string) error

StandbyNode sets a pacemaker node into standby

func (*CIB) StartResource

func (c *CIB) StartResource(id string) error

func (*CIB) StopResource

func (c *CIB) StopResource(id string) error

func (*CIB) UnStandbyNode added in v0.1.3

func (c *CIB) UnStandbyNode(nodeUname string) error

UnStandbyNode sets a pacemaker node out of standby

func (*CIB) Update

func (c *CIB) Update() error

func (*CIB) WaitForResourcesStop

func (c *CIB) WaitForResourcesStop(idsToStop []string) (bool, error)

WaitForResourcesStop waits for CRM resources to stop

It returns a flag indicating whether resources are stopped (true) or not (false), and an error.

type ClusterProperty

type ClusterProperty string
const (
	StonithEnabled ClusterProperty = "cib-bootstrap-options-stonith-enabled"
	ClusterName    ClusterProperty = "cib-bootstrap-options-cluster-name"
)

type LrmRunState

type LrmRunState string

LrmRunState represents the state of a CRM resource.

const (
	// Unknown means that the resource's state could not be retrieved
	Unknown LrmRunState = "Unknown"
	// Running means that the resource is verified as running
	Running LrmRunState = "Running"
	// Stopped means that the resource is verfied as stopped
	Stopped LrmRunState = "Stopped"
)

type Node added in v0.1.3

type Node struct {
	HostName string
	State    NodeState
}

type NodeState added in v0.1.1

type NodeState struct {
	InCCM        bool
	Crmd         bool
	Join         joinState
	JoinExpected joinState
}

Jump to

Keyboard shortcuts

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