nodes

package
v0.0.1-dev-d0185c6 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultIpmiDeviceId = uint8(0)
	IpmiMarkerfile      = "/etc/appliance/state/ipmi_detected"
)
View Source
const (
	Module             = "nodes"
	Db                 = "nodes"
	RequestsCollection = "requests"
	CollectionIpmi     = "ipmi"
)
View Source
const (
	RoleControl          = "control"
	RoleCompute          = "compute"
	RoleStorage          = "storage"
	RoleControlConverged = "control-converged"
	RoleModerator        = "moderator"
	RoleEdgeCore         = "edge-core"
)

Variables

View Source
var (
	Control          atomic.Pointer[Role]
	Compute          atomic.Pointer[Role]
	Storage          atomic.Pointer[Role]
	ControlConverged atomic.Pointer[Role]
	Moderator        atomic.Pointer[Role]
	EdgeCore         atomic.Pointer[Role]

	AllRoles        = []*Role{}
	AllGeneralRoles = []*Role{}
	ControlRoles    = []*Role{}
	ComputeRoles    = []*Role{}
)

Functions

func GenToken

func GenToken(hostname string) string

func GetCloudRoles

func GetCloudRoles() []string

func GetDiscoveredServices

func GetDiscoveredServices() ([]*registry.Service, error)

func GetEdgeRoles

func GetEdgeRoles() []string

func GetMap

func GetMap() map[string]Node

func GetSecretHeaders

func GetSecretHeaders() map[string]string

func HostnameMap

func HostnameMap() (map[string]Node, error)

func IsCloudRole

func IsCloudRole(role string) bool

func IsEdgeRole

func IsEdgeRole(role string) bool

func IsLocal

func IsLocal(hostname string) bool

func IsLocalAddress

func IsLocalAddress(address string) bool

func Lock

func Lock()

func SetAllGeneralRoles

func SetAllGeneralRoles()

func SetAllRoles

func SetAllRoles()

func SetComputeRoles

func SetComputeRoles()

func SetControlRoles

func SetControlRoles()

func SetList

func SetList(nodes []Node)

func Sync

func Sync()

func SyncEachRole

func SyncEachRole()

func SyncRoleCombination

func SyncRoleCombination()

func Unlock

func Unlock()

Types

type BlockDevice

type BlockDevice struct {
	Serial       string             `json:"serial"`
	Name         string             `json:"device" yaml:"device" bson:"device"`
	Type         string             `json:"type" yaml:"type" bson:"type"`
	SizeMiB      float64            `json:"sizeMiB" yaml:"sizeMiB" bson:"sizeMiB"`
	Availability string             `json:"availability" yaml:"availability" bson:"availability"`
	Status       status.BlockDevice `json:"status" yaml:"status" bson:"status"`
}

type Board

type Board struct {
	ManufacturingDate string `json:"manufacturingDate"`
	Manufacturer      string `json:"manufacturer"`
	Product           string `json:"product"`
	Serial            string `json:"serial"`
	PartNumber        string `json:"partNumber"`
}

type Host

type Host struct {
	Role string `json:"role,omitzero" bson:"role,omitzero"`
	Name string `json:"name" bson:"name"`
	Ip   string `json:"ip,omitzero" bson:"ip"`
}

func (*Host) GetNode

func (h *Host) GetNode() *Node

type ImpiValidation

type ImpiValidation struct {
	Board   `json:"board"`
	Product `json:"product"`
}

type Ipmi

type Ipmi struct {
	Host     string `json:"host" bson:"host"`
	Ip       string `json:"ip" bson:"ip"`
	Port     int    `json:"port" bson:"port"`
	Username string `json:"username" bson:"username"`
	Password string `json:"password" bson:"password"`
}

func (*Ipmi) CheckInvalidValues

func (i *Ipmi) CheckInvalidValues() error

type IpmiEnablement

type IpmiEnablement struct {
	IsSupported bool   `json:"isSupported" bson:"isSupported"`
	IsConnected bool   `json:"isConnected" bson:"isConnected"`
	Ip          string `json:"ip" bson:"ip"`
}

type NetworkInterface

type NetworkInterface struct {
	Interface   string `json:"interface" yaml:"interface" bson:"interface"`
	Label       string `json:"label" yaml:"label" bson:"label"`
	BusIdSlaves string `json:"busIdSlaves" yaml:"busIdSlaves" bson:"busIdSlaves"`
	Driver      string `json:"driver" yaml:"driver" bson:"driver"`
	State       string `json:"state" yaml:"state" bson:"state"`
	Speed       string `json:"speed" yaml:"speed" bson:"speed"`
}

type Node

type Node struct {
	Id           string `json:"id" yaml:"id"`
	SerialNumber string `json:"serialNumber" yaml:"serialNumber"`
	DataCenter   string `json:"dataCenter" yaml:"dataCenter"`
	Hostname     string `json:"hostname" yaml:"hostname" bson:"hostname"`
	Role         string `json:"role" yaml:"role"`

	Protocol     string `json:"protocol,omitempty" yaml:"protocol,omitempty"`
	Address      string `json:"address" yaml:"address"`
	Ip           string `json:"ip" yaml:"ip"`
	ManagementIP string `json:"managementIP" yaml:"managementIP"`
	StorageIP    string `json:"storageIP" yaml:"storageIP"`

	CpuSpec           string             `json:"cpuSpec" yaml:"cpuSpec"`
	NetworkInterfaces []NetworkInterface `json:"networkInterfaces" yaml:"networkInterfaces"`
	BlockDevices      []BlockDevice      `json:"blockDevices" yaml:"blockDevices"`
	Vcpu              metric.Compute     `json:"vcpu" yaml:"vcpu"`
	Memory            metric.Space       `json:"memory" yaml:"memory"`
	Storage           metric.Space       `json:"storage" yaml:"storage"`

	IsVirtualIpOwner bool `json:"isVirtualIpOwner" yaml:"isVirtualIpOwner"`
	IpmiEnablement   `json:"ipmi" yaml:"ipmi"`

	License       licenses.License `json:"license" yaml:"license,omitempty"`
	Status        string           `json:"status" yaml:"status" bson:"status"`
	UptimeSeconds float64          `json:"uptimeSeconds" yaml:"uptimeSeconds"`

	Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
}

func Get

func Get(hostname string) (*Node, error)

func GetControlNodes

func GetControlNodes() ([]Node, error)

func GetController

func GetController() (*Node, error)

func GetNodesByRole

func GetNodesByRole(role string) ([]Node, error)

func GetNodesByRoles

func GetNodesByRoles() []Node

func GetPeerControls

func GetPeerControls() ([]Node, error)

func List

func List() []Node

func ListPrevious

func ListPrevious() []Node

func New

func New(node *registry.Node) Node

func (*Node) CreateSupportFileUrl

func (n *Node) CreateSupportFileUrl(file support.File) string

func (*Node) DeleteModuleRepairingTaskUrl

func (n *Node) DeleteModuleRepairingTaskUrl(module string) string

func (*Node) DeleteRepairingTaskUrl

func (n *Node) DeleteRepairingTaskUrl() string

func (*Node) DeleteSupportFileUrl

func (n *Node) DeleteSupportFileUrl(group, file string) string

func (*Node) DownloadSupportFileUrl

func (n *Node) DownloadSupportFileUrl(setname, filename string) string

func (*Node) EnableOrDisableTuningUrl

func (n *Node) EnableOrDisableTuningUrl(tuning string) string

func (*Node) GenSearchableObject

func (n *Node) GenSearchableObject() Node

note: in the current search lib(bleve), we realize that it seems like not able to serach the status keyword from the single status field, but it's pretty tricky that it will work if we add the status behind any of fields below like hostname, address, managementIP... so that's why we do this for the time being in the M2, we will try to deep dive into the bleve and see if we can find a better way to do this

func (*Node) GenUrl

func (n *Node) GenUrl() string

func (*Node) GetMetricUrl

func (n *Node) GetMetricUrl(metric, view string) string

func (*Node) GetNodeUrl

func (n *Node) GetNodeUrl() string

func (*Node) GetSettingUrl

func (n *Node) GetSettingUrl(path string) string

func (*Node) GetSupportFileUrl

func (n *Node) GetSupportFileUrl() string

func (*Node) GetTuningUrl

func (n *Node) GetTuningUrl() string

func (*Node) IsDown

func (n *Node) IsDown() bool

func (*Node) IsLicenseExpired

func (n *Node) IsLicenseExpired() bool

func (*Node) IsLocal

func (n *Node) IsLocal() bool

func (*Node) IsUnlicensed

func (n *Node) IsUnlicensed() bool

func (*Node) IsUp

func (n *Node) IsUp() bool

func (*Node) MatchHardwareSerial

func (n *Node) MatchHardwareSerial(hardwareSerials []string) bool

func (*Node) PatchSettingTaskUrl

func (n *Node) PatchSettingTaskUrl(setting settings.Setting) string

func (*Node) PatchSupportFileTaskUrl

func (n *Node) PatchSupportFileTaskUrl(file support.File) string

func (*Node) PatchTriggerTaskUrl

func (n *Node) PatchTriggerTaskUrl(trigger triggers.ApiSchema) string

func (*Node) PatchTuningTaskUrl

func (n *Node) PatchTuningTaskUrl() string

func (*Node) PatchTuningUrl

func (n *Node) PatchTuningUrl(tuning string) string

func (*Node) PostLicenseUrl

func (n *Node) PostLicenseUrl() string

func (*Node) ResetTuningUrl

func (n *Node) ResetTuningUrl(tuning string) string

type Product

type Product struct {
	Manufacturer string `json:"manufacturer"`
	Name         string `json:"name"`
	Version      string `json:"version"`
	Serial       string `json:"serial"`
}

type RawBlockDevice

type RawBlockDevice struct {
	Type        string   `json:"type"`
	Serial      string   `json:"serial"`
	Name        string   `json:"name"`
	Size        string   `json:"size"`
	Rota        bool     `json:"rota"`
	MountPoints []string `json:"mountpoints"`
}

note: rota is named by lsblk tool, it means rotational device like HDD

func (*RawBlockDevice) IsBlock

func (r *RawBlockDevice) IsBlock() bool

func (*RawBlockDevice) IsPartition

func (r *RawBlockDevice) IsPartition() bool

func (*RawBlockDevice) NoMountPoints

func (r *RawBlockDevice) NoMountPoints() bool

type RawNetworkInterface

type RawNetworkInterface struct {
	Label       string `json:"label" yaml:"label" bson:"label"`
	BusIdSlaves string `json:"busid" yaml:"busid" bson:"busid"`
	Driver      string `json:"driver" yaml:"driver" bson:"driver"`
	State       string `json:"state" yaml:"state" bson:"state"`
	Speed       string `json:"speed" yaml:"speed" bson:"speed"`
}

type Role

type Role struct {
	Name  string `json:"name" bson:"name"`
	Hosts []Host `json:"hosts" bson:"hosts"`
	Nodes []Node `json:"-"`
}

func GetComputeRole

func GetComputeRole() *Role

func GetControlConvergeRole

func GetControlConvergeRole() *Role

func GetControlRole

func GetControlRole() *Role

func GetEdgeCoreRole

func GetEdgeCoreRole() *Role

func GetModeratorRole

func GetModeratorRole() *Role

func GetStorageRole

func GetStorageRole() *Role

func (*Role) IsNodeEmpty

func (r *Role) IsNodeEmpty() bool

type Selector

type Selector struct {
	Enabled bool              `json:"enabled" yaml:"enabled"`
	Labels  map[string]string `json:"labels" yaml:"labels"`
}

Jump to

Keyboard shortcuts

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