utils

package
v2.2.0-beta+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2019 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExitSuccess = iota
	ExitError
	ExitBadConnection
	ExitInvalidInput
	ExitBadFeature
	ExitInterrupted
	ExitIO
	ExitBadArgs = 128
)

Common exit flags

Variables

This section is empty.

Functions

func DelDataFromDb

func DelDataFromDb(db keyval.ProtoTxn, key string) error

func ExitWithError

func ExitWithError(code int, err error)

ExitWithError is used by all commands to print out an error and exit.

func GetAgentLabel

func GetAgentLabel(key string) (agentLabel string)

func GetDbForAllAgents

func GetDbForAllAgents(endpoints []string) (*kvproto.ProtoWrapper, error)

GetDbForAllAgents opens a connection to etcd, specified in the command line or the "ETCD_ENDPOINTS" environment variable.

func GetDbForOneAgent

func GetDbForOneAgent(endpoints []string, agentLabel string) (keyval.ProtoBroker, error)

GetDbForOneAgent opens a connection to etcd, specified in the command line or the "ETCD_ENDPOINTS" environment variable.

func GetModuleName

func GetModuleName(module proto.Message) string

func WriteData

func WriteData(db keyval.ProtoTxn, key string, json string)

Types

type EtcdDump

type EtcdDump map[string]*VppData

EtcdDump is a map of VppData records. It constitutes a temporary storage for data retrieved from etcd. "Temporary" means during the execution of an agentctl command. Every command reads data from etcd first, then processes it, and finally either outputs the processed data to the user or updates one or more data records in etcd.

func NewEtcdDump

func NewEtcdDump() EtcdDump

NewEtcdDump returns a new instance of the temporary storage that will hold data retrieved from etcd.

func (EtcdDump) PrintConfig

func (ed EtcdDump) PrintConfig(showConf bool) (*bytes.Buffer, error)

func (EtcdDump) PrintStatus

func (ed EtcdDump) PrintStatus() (*bytes.Buffer, error)

func (EtcdDump) ReadDataFromDb

func (ed EtcdDump) ReadDataFromDb(db keyval.ProtoBroker, key string,
	agent string) (found bool, err error)

ReadDataFromDb reads a data record from etcd, parses it according to the expected record type and stores it in the EtcdDump temporary storage. A record is identified by a Key.

The function returns an error if the etcd client encountered an error. The function returns true if the specified item has been found.

func (EtcdDump) ReadStatusDataFromDb

func (ed EtcdDump) ReadStatusDataFromDb(db keyval.ProtoBroker, key string,
	agent string) (found bool, err error)

type LogList

type LogList []logType

func ConvertToLogList

func ConvertToLogList(log string) LogList

func (LogList) PrintLogList

func (ll LogList) PrintLogList() (*bytes.Buffer, error)

type VppData

type VppData struct {
	Status    map[string]VppStatusWithMD
	Config    configurator.Config
	PrintConf bool
	ShowEtcd  bool
	ShowConf  bool
}

VppData defines a structure to hold all etcd data records (of all types) for one VPP.

type VppMetaData

type VppMetaData struct {
	Rev int64
	Key string
}

VppMetaData defines the etcd metadata.

type VppStatusWithMD

type VppStatusWithMD struct {
	VppMetaData
	status.AgentStatus
}

VppStatusWithMD contains a VPP Status data record and its etcd metadata.

Jump to

Keyboard shortcuts

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