tree

package
v0.0.0-...-1fc07e7 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2017 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenAlarmFromTemplate

func GenAlarmFromTemplate(ns string, data map[string]string, ID string) (model.Resource, error)

GenAlarmFromTemplate set the gourp infomation and return alarm.

Types

type DashboardInf

type DashboardInf interface {
	// GetDashboard return dashboard map of the ns.
	GetDashboard(ns string) (model.DashboardData, error)

	// SetDashboard set the dashboard map to the ns.
	SetDashboard(ns string, dashboardData model.DashboardData) error

	// AddDashboard add the dashboard to the ns.
	AddDashboard(ns string, dashboardData model.Dashboard) error

	// RemoveDashboard update the dashboard of the ns.
	RemoveDashboard(ns string, dIndex int) error

	// UpdateDashboard update the title of dashboard.
	UpdateDashboard(ns string, dIndex int, title string) error

	PanelInf
}

DashboardInf is interface the dashboard resource have.

type PanelInf

type PanelInf interface {
	// ReorderPanel update the panel order of a dashboard.
	ReorderPanel(ns string, dIndex int, newOrder []int) error

	// AddPanel add the panel to the dashboard.
	AddPanel(ns string, dIndex int, panel model.Panel) error

	// RemovePanel delete the panel of the dashboard.
	RemovePanel(ns string, dIndex int, panelIndex int) error

	// UpdatePanel update the panel of the dashboard.
	UpdatePanel(ns string, dIndex int, panelIndex int, title, graphType string) error

	// AppendTarget append a target to panel.
	AppendTarget(ns string, dIndex int, panelIndex int, target model.Target) error

	// UpdateTarget update a target.
	UpdateTarget(ns string, dIndex int, panelIndex, targetIndex int, target model.Target) error

	// RemoveTarget delete a target.
	RemoveTarget(ns string, dIndex int, panelIndex, targetIndex int) error
}

PanelInf is the panel method. Panel is picture a dashboard have.

type ReportInfo

type ReportInfo struct {
	sync.RWMutex
	ReportInfo reportMap
}

ReportInfo save the agent report infomation.

type Tree

type Tree struct {
	Nodes *node.Node

	Mu sync.RWMutex
	// contains filtered or unexported fields
}

Tree manage the node/resource/machine.

func NewTree

func NewTree(cluster cluster.Inf) (*Tree, error)

NewTree return Tree obj.

func (*Tree) AddDashboard

func (t *Tree) AddDashboard(ns string, dashboardData model.Dashboard) error

AddDashboard add a dashboard to a ns.

func (*Tree) AddPanel

func (t *Tree) AddPanel(ns string, dIndex int, panel model.Panel) error

AddPanel add a panel to a dashboard.

func (*Tree) AgentReport

func (t *Tree) AgentReport(info model.Report) error

AgentReport handle and save the agent report message.

func (*Tree) AllNodes

func (t *Tree) AllNodes() (n *node.Node, err error)

AllNodes return the root node.

func (*Tree) AppendResource

func (t *Tree) AppendResource(ns, resType string, appendRes ...model.Resource) error

AppendResource append resources to a ns.

func (*Tree) AppendTarget

func (t *Tree) AppendTarget(ns string, dIndex int, panelIndex int, target model.Target) error

AppendTarget append a target to panel.

func (*Tree) CheckMachineStatusByReport

func (t *Tree) CheckMachineStatusByReport(reports map[string]model.Report) error

CheckMachineStatusByReport check the machine is online or dead by its report, update the machine status.

func (*Tree) CopyResource

func (t *Tree) CopyResource(fromNs, toNs, resType string, resourceIDs ...string) error

CopyResource copy one resource from one ns to the other ns, the resource will still exist in the old ns.

func (*Tree) GetDashboard

func (t *Tree) GetDashboard(ns string) (model.DashboardData, error)

GetDashboard return the dashboard under the ns.

func (*Tree) GetNodeByNS

func (t *Tree) GetNodeByNS(ns string) (n *node.Node, err error)

GetNodeByNS return node by ns.

func (*Tree) GetReportInfo

func (t *Tree) GetReportInfo() map[string]model.Report

GetReportInfo return all report information.

func (*Tree) GetResource

func (t *Tree) GetResource(ns, resourceType string, stringresID ...string) ([]model.Resource, error)

GetResource return the one resource of the ns.

func (*Tree) GetResourceList

func (t *Tree) GetResourceList(ns, resourceType string) (*model.ResourceList, error)

GetResourceList return a type resource list of a node.

func (*Tree) LeafChildIDs

func (t *Tree) LeafChildIDs(ns string) (l []string, err error)

LeafChildIDs return leaf node of the ns.

func (*Tree) MachineUpdate

func (t *Tree) MachineUpdate(oldName string, updateMap map[string]string) error

MachineUpdate search the hostname and update the machine resource by updateMap.

func (*Tree) MarshalJSON

func (mj *Tree) MarshalJSON() ([]byte, error)

func (*Tree) MarshalJSONBuf

func (mj *Tree) MarshalJSONBuf(buf fflib.EncodingBuffer) error

func (*Tree) MoveResource

func (t *Tree) MoveResource(oldNs, newNs, resType string, resourceIDs ...string) error

MoveResource move one resource fo an other ns, the resouce will be removed from the old ns.

func (*Tree) NewNode

func (t *Tree) NewNode(name, comment, parentNs string, nodeType int, machineRegistRule ...string) (string, error)

NewNode create a node, return a pointer which point to node, and it bucketId. Property is preserved. First property argument is used as the machineReg.

func (*Tree) RegisterMachine

func (t *Tree) RegisterMachine(newMachine model.Resource) (map[string]string, error)

RegisterMachine search and register the machine to the node which match the hostname.

func (*Tree) RemoveDashboard

func (t *Tree) RemoveDashboard(ns string, dIndex int) error

RemoveDashboard one dashboard of ns.

func (*Tree) RemoveNode

func (t *Tree) RemoveNode(ns string) error

RemoveNode remove node from tree, remove bucket which save the resource.

func (*Tree) RemovePanel

func (t *Tree) RemovePanel(ns string, dIndex int, panelIndex int) error

RemovePanel remove a panel from a dashboard.

func (*Tree) RemoveResource

func (t *Tree) RemoveResource(ns, resourceType string, resID ...string) error

RemoveResource remove one resource from a node.

func (*Tree) RemoveStatusByHostname

func (t *Tree) RemoveStatusByHostname(hostname string) error

RemoveStatusByHostname search and remove the machine by hostname.

func (*Tree) RemoveTarget

func (t *Tree) RemoveTarget(ns string, dIndex int, panelIndex, targetIndex int) error

RemoveTarget remove update a target.

func (*Tree) ReorderPanel

func (t *Tree) ReorderPanel(ns string, dIndex int, newOrder []int) error

ReorderPanel update the order of panel by newOrder.

func (*Tree) SearchMachine

func (t *Tree) SearchMachine(hostname string) (map[string]string, error)

SearchMachine search the hostname in all node.

func (*Tree) SearchResource

func (t *Tree) SearchResource(ns, resType string, search model.ResourceSearch) (map[string]*model.ResourceList, error)

SearchResource search any preperty resource in the ns and its child ns.

func (*Tree) SetDashboard

func (t *Tree) SetDashboard(ns string, dashboards model.DashboardData) error

SetDashboard set the dashboard to a node.

func (*Tree) SetResource

func (t *Tree) SetResource(ns, resType string, l model.ResourceList) error

SetResource set the resource list to the ns.

func (*Tree) UnmarshalJSON

func (uj *Tree) UnmarshalJSON(input []byte) error

func (*Tree) UnmarshalJSONFFLexer

func (uj *Tree) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

func (*Tree) UpdateDashboard

func (t *Tree) UpdateDashboard(ns string, dIndex int, title string) error

UpdateDashboard update one dashboard title of ns.

func (*Tree) UpdateNode

func (t *Tree) UpdateNode(ns, name, comment, machineMatchStrategy string) error

UpdateNode update the node name or machineMatchStrategy.

func (*Tree) UpdatePanel

func (t *Tree) UpdatePanel(ns string, dIndex int, panelIndex int, title, graphType string) error

UpdatePanel update a panel.

func (*Tree) UpdateResource

func (t *Tree) UpdateResource(ns, resType, resID string, updateMap map[string]string) error

UpdateResource update one resource by updateMap.

func (*Tree) UpdateStatusByHostname

func (t *Tree) UpdateStatusByHostname(hostname string, updateMap map[string]string) error

UpdateStatusByHostname search the machine and update the status. updateMap is map[string]string{HostStatusProp: status}

func (*Tree) UpdateTarget

func (t *Tree) UpdateTarget(ns string, dIndex int, panelIndex, targetIndex int, target model.Target) error

UpdateTarget update a target.

type TreeMethod

type TreeMethod interface {
	DashboardInf

	// NewNode create node.
	NewNode(name, comment, parentNs string, nodeType int, property ...string) (string, error)

	// Update the node property.
	UpdateNode(ns string, name, comment, machineReg string) error

	// RemoveNode remove the node with delID from parentNs.
	RemoveNode(ns string) error
	// contains filtered or unexported methods
}

TreeMethod is the interface tree must implement.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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