api

package
v0.0.0-...-7d01e72 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: GPL-3.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Routehandler http.Handler // set from main

Functions

func CreatePrimitiveHandler

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

func DeletePrimitiveHandler

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

func FetchClusterDetails

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

func FetchResourceClasses

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

func FetchResourceMetaAttributes

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

func FetchResourceOperationAttributes

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

func FetchResourceOperations

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

func FetchResourceParams

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

func FetchResourceProviders

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

func FetchResourceTypes

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

func RaClassesHandler

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

func RenamePrimitiveHandler

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

func ResourceEditHandler

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

This function does the magic routing between Go and Ruby

func SubmitResourceMetaAttributes

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

func SubmitResourceOperationAttributes

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

func SubmitResourceOperations

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

func SubmitResourceParams

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

func UpdatePrimitiveHandler

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

Types

type Action

type Action struct {
	Name     string `xml:"name,attr"`
	Timeout  string `xml:"timeout,attr"`
	Interval string `xml:"interval,attr"`
	Depth    string `xml:"depth,attr"`
	// We take CibID later from cib, if they are defined
	CibID string
	// Default values
	OpDefaults []MetaParameter
	// Help info
	Shortdesc string
	Longdesc  string
}

TODO: Action struct is messy. It's used for both to parse cib.xml * and to store the default values of operations. * Maybe there should be two different structures * (however I might change my mind, so don't hastle with it (17.05.2025))

type CIB

type CIB struct {
	XMLName        xml.Name      `xml:"cib"`
	ValidateWith   string        `xml:"validate-with,attr"`
	Epoch          string        `xml:"epoch,attr"`
	NumUpdates     string        `xml:"num_updates,attr"`
	AdminEpoch     string        `xml:"admin_epoch,attr"`
	CibLastWritten string        `xml:"cib-last-written,attr"`
	UpdateOrigin   string        `xml:"update-origin,attr"`
	UpdateClient   string        `xml:"update-client,attr"`
	UpdateUser     string        `xml:"update-user,attr"`
	HaveQuorum     string        `xml:"have-quorum,attr"`
	DcUuid         string        `xml:"dc-uuid,attr"`
	Configuration  Configuration `xml:"configuration"`
	Status         Status        `xml:"status"`
}

type ClusterPropertySet

type ClusterPropertySet struct {
	ID      string   `xml:"id,attr"`
	NVPairs []Nvpair `xml:"nvpair"`
}

type Configuration

type Configuration struct {
	CrmConfig   CrmConfig   `xml:"crm_config"`
	Node        []Node      `xml:"nodes>node"`
	Constraints Constraints `xml:"constraints"`
	Primitives  []Primitive `xml:"resources>primitive"`
}

type Constraints

type Constraints struct {
	Colocations []RscColocation `xml:"rsc_colocation"`
	Locations   []RscLocation   `xml:"rsc_location"`
}

type ContentAttr

type ContentAttr struct {
	Type    string `xml:"type,attr"`
	Default string `xml:"default,attr"`
	// Possible values are hardcoded
	PossibleValues []string
	// We take CibID and CibValue later from cib, if they are defined
	Required string // string, so that ["true", "false", "" for undefined]
	CibID    string // "" in case of operation attributes, the Action.CibID is used instead
	CibValue string
}

type CrmConfig

type CrmConfig struct {
	ClusterPropertySet ClusterPropertySet `xml:"cluster_property_set"`
}

type CrmNode

type CrmNode struct {
	Name        string `xml:"name,attr"`
	ID          string `xml:"id,attr"`
	Online      bool   `xml:"online,attr"`
	Maintenance bool   `xml:"maintenance,attr"`
}

type CrmResourceMetadata

type CrmResourceMetadata struct {
	Name       string          `xml:"name,attr"`
	Version    string          `xml:"version,attr"`
	Longdesc   string          `xml:"longdesc"`
	Shortdesc  string          `xml:"shortdesc"`
	Parameters []MetaParameter `xml:"parameters>parameter"` // maps to instance_attributes
	Actions    []Action        `xml:"actions>action"`
	/* RscDefaults (#meta_attributes) is not in 'crm_resource --show-metadata'
	 * but it's copied from rscDefaults
	 * and later enriched from 'cibadmin' */
	RscDefaults []MetaParameter
}

type CrmResourceRow

type CrmResourceRow struct {
	ID          string
	Type        string
	Node        string
	Status      string
	Maintenance bool
}

func ToCrmResourceRows

func ToCrmResourceRows(crm CrmStatus) []CrmResourceRow

flatten the CrmStatus for the easier UI

type CrmRsc

type CrmRsc struct {
	ID            string       `xml:"id,attr"`
	ResourceAgent string       `xml:"resource_agent,attr"`
	Role          string       `xml:"role,attr"`
	TargetRole    string       `xml:"target_role,attr"`
	Active        bool         `xml:"active,attr"`
	Maintenance   bool         `xml:"maintenance,attr"`
	Managed       bool         `xml:"managed,attr"`
	Nodes         []CrmRscNode `xml:"node"`
}

type CrmRscNode

type CrmRscNode struct {
	Name   string `xml:"name,attr"`
	ID     string `xml:"id,attr"`
	Cached bool   `xml:"cached,attr"`
}

type CrmStatus

type CrmStatus struct {
	XMLName   xml.Name  `xml:"crm_mon"`
	Nodes     []CrmNode `xml:"nodes>node"`
	Resources []CrmRsc  `xml:"resources>resource"`
}

func GetCrmStatus

func GetCrmStatus() (CrmStatus, error)

type InstanceAttribute

type InstanceAttribute struct {
	ID      string   `xml:"id,attr" json:"id"`
	NVPairs []Nvpair `xml:"nvpair" json:"nvpair"`
}

type LRM

type LRM struct {
	Resources []LRMResource `xml:"lrm_resources>lrm_resource"`
}

type LRMOp

type LRMOp struct {
	ID        string `xml:"id,attr"`
	Operation string `xml:"operation,attr"`
	OpStatus  string `xml:"op-status,attr"`
	RCCode    string `xml:"rc-code,attr"`
}

type LRMResource

type LRMResource struct {
	ID    string  `xml:"id,attr"`
	Class string  `xml:"class,attr"`
	Type  string  `xml:"type,attr"`
	Ops   []LRMOp `xml:"lrm_rsc_op"`
}

type MetaAttribute

type MetaAttribute struct {
	ID      string   `xml:"id,attr" json:"id"`
	NVPairs []Nvpair `xml:"nvpair" json:"nvpair"`
}

type MetaParameter

type MetaParameter struct {
	Name      string      `xml:"name,attr"`
	Longdesc  string      `xml:"longdesc"`
	Shortdesc string      `xml:"shortdesc"`
	Content   ContentAttr `xml:"content"`
}

func GetOpDefaults

func GetOpDefaults() []MetaParameter

func GetOpDescriptions

func GetOpDescriptions() []MetaParameter

func GetRscDefaults

func GetRscDefaults() []MetaParameter

type NameValue

type NameValue struct {
	Name  string `json:"Name"`
	Value string `json:"Value"`
}

type Node

type Node struct {
	ID    string `xml:"id,attr"`
	Uname string `xml:"uname,attr"`
}

type NodeRow

type NodeRow struct {
	ID     string
	Name   string
	Status string
}

type NodeState

type NodeState struct {
	Uname string `xml:"uname,attr"`
	LRM   LRM    `xml:"lrm"`
}

type Nvpair

type Nvpair struct {
	XMLName xml.Name `xml:"nvpair" json:"nvpair"`
	ID      string   `xml:"id,attr" json:"id"`
	Name    string   `xml:"name,attr" json:"name"`
	Value   string   `xml:"value,attr" json:"value"`
}

type Operation

type Operation struct {
	XMLName     xml.Name `xml:"op"`
	Description string   `xml:"description,attr,omitempty"`
	Depth       string   `xml:"depth,attr,omitempty"`
	ID          string   `xml:"id,attr"`
	Interval    string   `xml:"interval,attr,omitempty"`
	Name        string   `xml:"name,attr"`
	Timeout     string   `xml:"timeout,attr,omitempty"`
}

don't confuse it with Action. * Action is "crm_resource --show-metadata ocf:pacemaker:Dummy" * Operation is "cibamdin -Ql"

type OperationContent

type OperationContent struct {
	Options []OperationOption `json:"Options"`
}

type OperationOption

type OperationOption struct {
	Name           string      `json:"Name"`
	DefaultValues  []NameValue `json:"DefaultValues"`
	Shortdesc      string      `json:"Shortdesc"`
	Longdesc       string      `json:"Longdesc"`
	Type           string      `json:"Type"`
	PossibleValues []string    `json:"PossibleValues"`
	Required       string      `json:"Required"` // string, so that ["true", "false", "" for undefined]
	// FIXME: in case of operations, there might be many CibIDs and each id has several values [interval, timeout,...]
	CibID string `json:"CibID"`
	/* CibNameValues is kinda hacky thing.
	 * If it's instance or meta attribute there should be
	 *    `CibValue string` instead, not an array `[]NameValue`
	 * For example
	 *    `<nvpair id="dummy1-instance_attributes-envfile" name="envfile" value="/etc/sysconfyg/hawk"/>`
	 * Hoever an operation may contain many key-values
	 *     `<op id="dummy1-monitor-5" interval="5" name="monitor" timeout="22"/>`
	 * e.i. interval=5, timeout=22, so we use []NameValue for both
	 * The convention is that the name is empty for instance and meta attributes NameValue{"", CibValue} */
	CibNameValues []NameValue `json:"CibNameValues"`
}

type Primitive

type Primitive struct {
	XMLName            xml.Name          `xml:"primitive"` // w/o it, marshalled xml would be 'Primitive' (not 'primitive')
	ID                 string            `xml:"id,attr" json:"id"`
	Class              string            `xml:"class,attr" json:"class"`
	Provider           string            `xml:"provider,attr" json:"provider"`
	Type               string            `xml:"type,attr" json:"type"`
	MetaAttributes     MetaAttribute     `xml:"meta_attributes" json:"meta_attributes"`
	InstanceAttributes InstanceAttribute `xml:"instance_attributes" json:"instance_attributes"`
	Operations         []Operation       `xml:"operations>op" json:"operations"`
}

type ResourceRow

type ResourceRow struct {
	ID             string
	Class          string
	Provider       string
	Type           string
	Node           string
	Status         string
	TargetRole     string
	Constraints    Constraints
	MetaAttributes []Nvpair
}

type RscColocation

type RscColocation struct {
	ID      string `xml:"id,attr"`
	Score   string `xml:"score,attr"`
	Rsc     string `xml:"rsc,attr"`
	WithRsc string `xml:"with-rsc,attr"`
}

To add colocation constraint: crm configure colocation location_constration 5000: dummy1 dummy2

type RscLocation

type RscLocation struct {
	ID    string `xml:"id,attr"`
	Score string `xml:"score,attr"`
	Rsc   string `xml:"rsc,attr"`
	Node  string `xml:"node,attr"`
}

type SelectContent

type SelectContent struct {
	Longdesc  string         `json:"Longdesc"`
	Shortdesc string         `json:"Shortdesc"`
	Options   []SelectOption `json:"Options"`
}

Response data.

type SelectOption

type SelectOption struct {
	Name           string   `json:"Name"`
	DefaultValue   string   `json:"DefaultValue"`
	Shortdesc      string   `json:"Shortdesc"`
	Longdesc       string   `json:"Longdesc"`
	Type           string   `json:"Type"`
	PossibleValues []string `json:"PossibleValues"`
	Required       string   `json:"Required"` // string, so that ["true", "false", "" for undefined]
	CibID          string   `json:"CibID"`
	CibValue       string   `json:"CibValue"`
}

it's like MetaParameter, but ContentAttr is flattened it has nothing to do with parsing xml, it's in the structure conveniet to work with in the js

type Status

type Status struct {
	NodeStates []NodeState `xml:"node_state"`
}

Jump to

Keyboard shortcuts

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