v1

package
v0.0.1-dev-9e1fe1c Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Tokens = "tokens"
	Logout = "logout"
)
View Source
const (
	Summary = "summary"
	Metrics = "metrics"
)
View Source
const (
	RoleControl          = "control"
	RoleCompute          = "compute"
	RoleStorage          = "storage"
	RoleNetwork          = "network"
	RoleControlConverged = "control-converged"
	RoleModerator        = "moderator"
	RoleEdgeCore         = "edge-core"
)
View Source
const (
	ISO8601 = "2006-01-02T15:04:05"
	RFC3339 = time.RFC3339
)
View Source
const (
	ApiDoc = "api-doc"
)
View Source
const (
	DataCenters = "datacenters"
)
View Source
const (
	Events = "events"
)
View Source
const (
	Healths = "healths"
)
View Source
const (
	Integrations = "integrations"
)
View Source
const (
	Licenses = "licenses"
)
View Source
const (
	Me = "me"
)
View Source
const (
	NetMajorInterface = "eth0"
)
View Source
const (
	Nodes = "nodes"
)
View Source
const (
	Tunings = "tunings"
)

Variables

View Source
var (
	DefaultKeycloakRealm       = "master"
	DefaultIdpSamlMetadataPath = fmt.Sprintf("/auth/realms/%s/protocol/saml/descriptor", DefaultKeycloakRealm)
	DefaultSpSamlMetadataPath  = "/saml/metadata"
	DefaultApiServerKey        = "/var/www/certs/server.key"
	DefaultApiServerCert       = "/var/www/certs/server.cert"
	DefaultIdentifierFormat    = "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent"

	DefaultOidcClientId     = "token-connect"
	DefaultOidcClientSecret = ""
	DefaultOidcClientOpts   = gocloak.Client{
		ClientID:                  gocloak.StringP(DefaultOidcClientId),
		Protocol:                  gocloak.StringP("openid-connect"),
		PublicClient:              gocloak.BoolP(true),
		StandardFlowEnabled:       gocloak.BoolP(true),
		DirectAccessGrantsEnabled: gocloak.BoolP(true),
		Attributes: &map[string]string{
			"access.token.lifespan": "7200",
		},
	}

	LogoutRedirectUrl = ""
)
View Source
var (
	HostID            string
	Hostname          string
	DataCenterName    string
	DataCenterVersion string
	DataCenterVip     string
	ListenAddr        string
	ListenPort        int
	AdvertiseAddr     string
	AdvertisePort     int
	MgmtNet           string
	MgmtIP            string
	IsHaEnabled       bool
	IsGpuEnabled      bool
)
View Source
var (
	CurrentRole string
	Roles       = []string{RoleControl, RoleCompute, RoleStorage, RoleNetwork, RoleControlConverged, RoleModerator, RoleEdgeCore}

	ControlRole          = newControlRole()
	ComputeRole          = newComputeRole()
	StorageRole          = newStorageRole()
	NetworkRole          = newNetworkRole()
	ControlConvergedRole = newControlConvergeRole()
	ModeratorRole        = newModeratorRole()
	EdgeCoreRole         = newEdgeCoreRole()

	AllRoles = []*Role{
		ControlRole,
		ComputeRole,
		StorageRole,
		NetworkRole,
		ControlConvergedRole,
		ModeratorRole,
		EdgeCoreRole,
	}

	AllGeneralRoles = []*Role{
		ControlRole,
		ComputeRole,
		StorageRole,
		NetworkRole,
		ControlConvergedRole,
	}

	ControlRoles = []*Role{
		ControlRole,
		ControlConvergedRole,
	}

	ComputeRoles = []*Role{
		ComputeRole,
		ControlConvergedRole,
		EdgeCoreRole,
	}
)
View Source
var (
	CreateRecordIfNotExist = options.Update().SetUpsert(true)
)

Functions

func CapturePanic

func CapturePanic()

func GenerateNodeHashByMacAddr

func GenerateNodeHashByMacAddr() (string, error)

func GetAllTunings

func GetAllTunings() *sync.Map

func GetMacAddr

func GetMacAddr(interfaceName string) (string, error)

func HealthDB

func HealthDB() string

func IsPageRequired

func IsPageRequired(pageNum, pageSize string) bool

func RepairCollection

func RepairCollection() string

func SetSpecToTuning

func SetSpecToTuning(tuningName string, tuningSpec *TuningSpec)

func SeverityFullName

func SeverityFullName(severity string) string

func ShouldCurrentRoleHandleTheTuning

func ShouldCurrentRoleHandleTheTuning(tuningName string, roleName string) bool

func SyncNodesOfRole

func SyncNodesOfRole()

func TimeLocalISO8601

func TimeLocalISO8601(t time.Time) string

func TimeNowRFC3339

func TimeNowRFC3339() string

func TimeRFC3339

func TimeRFC3339(duration time.Duration) string

func TimeUTC

func TimeUTC(t time.Time) string

func TuningCollection

func TuningCollection(name string) string

func TuningDB

func TuningDB() string

Types

type ComputeStatistic

type ComputeStatistic struct {
	TotalCores  int     `json:"totalCores"`
	UsedCores   int     `json:"usedCores"`
	UsedPercent float64 `json:"usedPercent"`
	FreeCores   int     `json:"freeCores"`
	FreePercent float64 `json:"freePercent"`
}

type DataCenter

type DataCenter struct {
	Id          string `json:"id,omitempty" bson:"id"`
	Name        string `json:"name" bson:"name"`
	Version     string `json:"version" bson:"version"`
	VirtualIp   string `json:"virtualIp" bson:"virtualIp"`
	IsLocal     bool   `json:"isLocal" bson:"isLocal"`
	IsHaEnabled bool   `json:"isHaEnabled" bson:"isHaEnabled"`
}

func (*DataCenter) SetDetailsByInitedInfo

func (d *DataCenter) SetDetailsByInitedInfo()

M1 TODO: have to think about if we 1). need to add the Id of datacenter 2). if (1) is true, then what's factor to generate the Id

type Event

type Event struct {
	Type        string                 `json:"type"`
	Severity    string                 `json:"severity"`
	Id          string                 `json:"id"`
	Description string                 `json:"description"`
	Host        string                 `json:"host"`
	Category    string                 `json:"category"`
	Service     string                 `json:"service"`
	Metadata    map[string]interface{} `json:"metadata"`
	Time        string                 `json:"time"`
}

type ExampleValue

type ExampleValue struct {
	Type    string      `json:"type"`
	Default interface{} `json:"default"`
	Min     interface{} `json:"min"`
	Max     interface{} `json:"max"`
}

type Expiry

type Expiry struct {
	Date string `json:"date" yaml:"date" bson:"date"`
	Days int    `json:"days" yaml:"days" bson:"days"`
}

type Feature

type Feature struct {
	Name string `json:"name" yaml:"name" bson:"name"`
}

type Health

type Health struct {
	Category string         `json:"category"`
	Service  string         `json:"service"`
	Status   status.Details `json:"status,omitempty" yaml:"status,omitempty" bson:"status,omitempty"`
	Modules  []Module       `json:"modules"`
}

type HostNetworkPacket

type HostNetworkPacket struct {
	Id      string  `json:"id"`
	Name    string  `json:"name"`
	Packets float64 `json:"packets"`
}

type HostPercentageUsage

type HostPercentageUsage struct {
	Id          string  `json:"id"`
	Name        string  `json:"name"`
	UsedPercent float64 `json:"usedPercent"`
	FreePercent float64 `json:"freePercent"`
}

type Integration

type Integration struct {
	Name                    string `json:"name"`
	IsHeaderShortcutEnabled bool   `json:"isHeaderShortcutEnabled"`
	Description             string `json:"description"`
	IsBuiltIn               bool   `json:"isBuiltIn"`
	Url                     string `json:"url"`
}

type Issue

type Issue struct {
	By       string `json:"by" yaml:"by" bson:"by"`
	To       string `json:"to" yaml:"to" bson:"to"`
	Hardware string `json:"hardware" yaml:"hardware" bson:"hardware"`
	Date     string `json:"date" yaml:"date" bson:"date"`
}

type Label

type Label struct {
	Key   string `json:"key" yaml:"key"`
	Value string `json:"value" yaml:"value"`
}

type License

type License struct {
	Type                  string `json:"type" yaml:"type" bson:"type"`
	Hostname              string `json:"hostname" yaml:"hostname" bson:"hostname"`
	Serial                string `json:"serial" yaml:"serial" bson:"serial"`
	Product               `json:"product" yaml:"product" bson:"product"`
	Issue                 `json:"issue" yaml:"issue" bson:"issue"`
	Quantity              `json:"quantity" yaml:"quantity" bson:"quantity"`
	ServiceLevelAgreement `json:"serviceLevelAgreement" yaml:"sla" bson:"serviceLevelAgreement"`
	Expiry                `json:"expiry" yaml:"expiry" bson:"expiry"`
}

type Limit

type Limit struct {
	Number      int    `json:"number"`
	Description string `json:"description"`
}

type Module

type Module struct {
	Name             string         `json:"name" bson:"name"`
	Status           status.Details `json:"status,omitempty" bson:"status,omitempty"`
	IsAutoRepairable bool           `json:"-" bson:"isAutoRepairable"`
	Description      string         `json:"description,omitempty" bson:"description"`
}

type Node

type Node struct {
	Id            string `json:"id" yaml:"id"`
	Hostname      string `json:"hostname" yaml:"hostname"`
	Role          string `json:"role" yaml:"role"`
	Protocol      string `json:"protocol,omitempty" yaml:"protocol,omitempty" bson:"protocol,omitempty"`
	Address       string `json:"address" yaml:"address"`
	ManagementIP  string `json:"managementIP" yaml:"managementIP"`
	License       `json:"license,omitempty" yaml:"license,omitempty" bson:"license,omitempty"`
	Status        string            `json:"status" yaml:"status"`
	Vcpu          ComputeStatistic  `json:"vcpu" yaml:"vcpu" bson:"vcpu"`
	Memory        SpaceStatistic    `json:"memory" yaml:"memory" bson:"memory"`
	Storage       SpaceStatistic    `json:"storage" yaml:"storage" bson:"storage"`
	UptimeSeconds float64           `json:"uptimeSeconds" yaml:"uptimeSeconds" bson:"uptimeSeconds"`
	Labels        map[string]string `json:"labels,omitempty" yaml:"labels,omitempty" bson:"labels,omitempty"`
}

func GetControllerNodes

func GetControllerNodes() ([]*Node, error)

func GetNodesByRole

func GetNodesByRole(roleName string) ([]*Node, error)

func ListNodes

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

type Page

type Page struct {
	Total  int64 `json:"total"`
	Number int   `json:"number"`
	Size   int   `json:"size"`
}

func (Page) IsRequired

func (p Page) IsRequired() bool

type Period

type Period struct {
	Start string
	Stop  string
}

type Policy

type Policy struct {
	Name    string   `json:"name" yaml:"name"`
	Version string   `json:"version" yaml:"version"`
	Enabled bool     `json:"enabled" yaml:"enabled"`
	Tunings []Tuning `json:"tunings" yaml:"tunings"`
}

func (*Policy) AppendTunings

func (t *Policy) AppendTunings(tunings []Tuning)

func (*Policy) DeleteTuning

func (t *Policy) DeleteTuning(tuningName string)

type Product

type Product struct {
	Name     string    `json:"name" yaml:"name" bson:"name"`
	Features []Feature `json:"features" yaml:"features" bson:"features"`
}

type Quantity

type Quantity struct {
	Type  string `json:"type" yaml:"type" bson:"type"`
	Value int    `json:"vcpu" yaml:"vcpu" bson:"vcpu"`
}

type RawLicense

type RawLicense struct {
	Type     string `json:"type" yaml:"type" bson:"type"`
	Hostname string `json:"hostname" yaml:"hostname" bson:"hostname"`
	Serial   string `json:"serial" yaml:"serial" bson:"serial"`
	Check    int    `json:"check" yaml:"check" bson:"check"`
	IssueBy  string `json:"issueby" yaml:"issueby" bson:"issueby"`
	IssueTo  string `json:"issueto" yaml:"issueto" bson:"issueto"`
	Hardware string `json:"hardware" yaml:"hardware" bson:"hardware"`
	Expiry   string `json:"expiry" yaml:"expiry" bson:"expiry"`
	Date     string `json:"date" yaml:"date" bson:"date"`
	Days     int    `json:"days" yaml:"days" bson:"days"`
}

type Role

type Role struct {
	Name  string  `json:"name" bson:"name"`
	Nodes []*Node `json:"nodes" bson:"nodes"`
}

func GetComputeRole

func GetComputeRole() *Role

func GetControlConvergeRole

func GetControlConvergeRole() *Role

func GetControlRole

func GetControlRole() *Role

func GetControlRoles

func GetControlRoles() []*Role

func GetEdgeCoreRole

func GetEdgeCoreRole() *Role

func GetModeratorRole

func GetModeratorRole() *Role

func GetNetworkRole

func GetNetworkRole() *Role

func GetRolesToHandleTuning

func GetRolesToHandleTuning(tuningName string) ([]*Role, bool)

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"`
}

type Service

type Service struct {
	Name     string         `json:"service" bson:"service"`
	Category string         `json:"category" bson:"category"`
	Status   status.Details `json:"status,omitempty" bson:"status,omitempty"`
	Modules  []Module       `json:"modules" bson:"modules"`
}

func (Service) CopyModuleEmptyStruct

func (s Service) CopyModuleEmptyStruct() Service

type ServiceLevelAgreement

type ServiceLevelAgreement struct {
	Uptime                 float32 `json:"uptime" yaml:"uptime" bson:"uptime"`
	Period                 string  `json:"period" yaml:"period" bson:"period"`
	MeanTimeBetweenFailure string  `json:"meanTimeBetweenFailure" yaml:"meanTimeBetweenFailure" bson:"meanTimeBetweenFailure"`
	MeanTimeToRecovery     string  `json:"meanTimeToRecovery" yaml:"meanTimeToRecovery" bson:"meanTimeToRecovery"`
}

type SpaceStatistic

type SpaceStatistic struct {
	TotalMiB    float64 `json:"totalMiB"`
	UsedMiB     float64 `json:"usedMiB"`
	UsedPercent float64 `json:"usedPercent"`
	FreeMiB     float64 `json:"freeMiB"`
	FreePercent float64 `json:"freePercent"`
}

type StorageBandwidthSeries

type StorageBandwidthSeries struct {
	Read  []TimeBytesPoint `json:"read"`
	Write []TimeBytesPoint `json:"write"`
}

type StorageIopsSeries

type StorageIopsSeries struct {
	Read  []TimeOpsPoint `json:"read"`
	Write []TimeOpsPoint `json:"write"`
}

type StorageLatencySeries

type StorageLatencySeries struct {
	Read  []TimeLatencyPoint `json:"read"`
	Write []TimeLatencyPoint `json:"write"`
}

type TimeBytesPoint

type TimeBytesPoint struct {
	Time  string  `json:"time"`
	Bytes float64 `json:"bytes"`
}

type TimeLatencyPoint

type TimeLatencyPoint struct {
	Time string  `json:"time"`
	Ms   float64 `json:"ms"`
}

type TimeOpsPoint

type TimeOpsPoint struct {
	Time string  `json:"time"`
	Ops  float64 `json:"ops"`
}

type TrafficStatistic

type TrafficStatistic struct {
	Ingress float64 `json:"ingress"`
	Egress  float64 `json:"egress"`
}

type Tuning

type Tuning struct {
	Enabled bool   `json:"enabled" yaml:"enabled"`
	Name    string `json:"name" yaml:"name"`
	Value   string `json:"value" yaml:"value"`

	Node   `json:"node,omitempty" yaml:"node,omitempty" bson:"node,omitempty"`
	Status status.Details `json:"status,omitempty" yaml:"status,omitempty" bson:"status,omitempty"`
}

func (*Tuning) Bytes

func (t *Tuning) Bytes() ([]byte, error)

func (*Tuning) SetNodeInfo

func (t *Tuning) SetNodeInfo(role, address string)

type TuningSpec

type TuningSpec struct {
	Name         string `json:"name"`
	ExampleValue `json:"exampleValue"`
	Description  string  `json:"description"`
	Roles        []*Role `json:"roles"`
	Selector     `json:"selector"`
}

type Usage

type Usage struct {
	Vcpu    ComputeStatistic `json:"vcpu"`
	Memory  SpaceStatistic   `json:"memory"`
	Storage SpaceStatistic   `json:"storage"`
}

type User

type User struct {
	Name     string `json:"name"`
	Password string `json:"password"`
}

func (User) IsNameEmpty

func (u User) IsNameEmpty() bool

func (User) IsPasswordEmpty

func (u User) IsPasswordEmpty() bool

type VmMetricsUsage

type VmMetricsUsage struct {
	Id          string  `json:"id"`
	Name        string  `json:"name"`
	Device      string  `json:"device,omitempty"`
	Usage       float64 `json:"usage"`
	UsedPercent float64 `json:"usedPercent"`
	FreePercent float64 `json:"freePercent"`
}

type VmPercentageUsage

type VmPercentageUsage struct {
	Id          string  `json:"id"`
	Name        string  `json:"name"`
	UsedPercent float64 `json:"usedPercent"`
	FreePercent float64 `json:"freePercent"`
}

Jump to

Keyboard shortcuts

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