server

package
v0.0.0-...-308df95 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2021 License: BSD-2-Clause, BSD-3-Clause, LGPL-2.1, + 2 more Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoPrefix   = "TEST_NOT_USING_PREFIX"
	InvalidPos = -1
)
View Source
const (
	DefaultTimeout = 600
)

Variables

This section is empty.

Functions

func IsLoginPidError

func IsLoginPidError(err error) bool

func MakeNodeRef

func MakeNodeRef(ps []string, startNode schema.Node) xutils.NodeRef

MakeNodeRef

Used to convert a config path string ([]string) to the NodeRef format that looks like a XPath leafref-type reference to a node.

NB:

(1) startNode represents root node

(2) ps represents path to leaf / leaf-list schema node, but NOT
    to the value node underneath.  Think of NodeRefs as references
    to a node generically, rather than to a specific value of that
    node.

(3) All NodeRefs are absolute, not relative.

(4) We generate a single element in the NodeRef for List+ListEntry.
    We get the key name from the List, and save it for use with the
    extra data we get from the ListEntry

(5) This ought to be in configd/pathutil but with the schema reference
    we end up with a circular reference to packages via the configd/exec
    package and it all gets very messy trying to unentangle it.  Exercise
    for the reader on another day ...

Types

type ConfirmedCommitInfo

type ConfirmedCommitInfo struct {
	Session   string `json:"session"`
	PersistId string `json:"persist-id"`
}

type Disp

type Disp struct {
	// contains filtered or unexported fields
}

func (*Disp) AuthAuthorize

func (d *Disp) AuthAuthorize(path string, perm int) (bool, error)

func (*Disp) AuthGetPerms

func (d *Disp) AuthGetPerms() (map[string]string, error)

func (*Disp) CallRpc

func (d *Disp) CallRpc(moduleIdOrNamespace, rpcName, args, encoding string,
) (string, error)

func (*Disp) CallRpcXml

func (d *Disp) CallRpcXml(moduleNamespace, name, args string) (string, error)

TODO: eventually remove this.

func (*Disp) CancelCommit

func (d *Disp) CancelCommit(sid, comment, persistid string, force, debug bool) (string, error)

func (*Disp) Comment

func (d *Disp) Comment(sid string, path string) (bool, error)

func (*Disp) Commit

func (d *Disp) Commit(
	sid string,
	message string,
	debug bool,
) (string, error)

func (*Disp) CommitConfirm

func (d *Disp) CommitConfirm(
	sid string,
	message string,
	debug bool,
	mins int,
) (string, error)

func (*Disp) Compare

func (d *Disp) Compare(old, new, spath string, ctxdiff bool) (string, error)

func (*Disp) CompareConfigRevisions

func (d *Disp) CompareConfigRevisions(sid, revOne, revTwo string) (string, error)

func (*Disp) CompareSessionChanges

func (d *Disp) CompareSessionChanges(sid string) (string, error)

func (*Disp) Confirm

func (d *Disp) Confirm(sid string) (string, error)

func (*Disp) ConfirmPersistId

func (d *Disp) ConfirmPersistId(persistid string) (string, error)

func (*Disp) ConfirmSilent

func (d *Disp) ConfirmSilent(sid string) (string, error)

func (*Disp) ConfirmedCommit

func (d *Disp) ConfirmedCommit(
	sid string,
	message string,
	confirmed bool,
	timeout string,
	persist string,
	persistid string,
	debug bool,
) (string, error)

func (*Disp) ConfirmingCommit

func (d *Disp) ConfirmingCommit() (string, error)

func (*Disp) Copy

func (d *Disp) Copy(sid string, fpath string, tpath string) (bool, error)

func (*Disp) CopyConfig

func (d *Disp) CopyConfig(
	sid,
	sourceDatastore,
	sourceEncoding,
	sourceConfig,
	sourceURL,
	targetDatastore,
	targetURL string,
) (string, error)

func (*Disp) Delete

func (d *Disp) Delete(sid string, path string) (bool, error)

func (*Disp) Discard

func (d *Disp) Discard(sid string) (bool, error)

func (*Disp) EditConfigXML

func (d *Disp) EditConfigXML(sid, config_target, default_operation, test_option, error_option, config string) (string, error)

func (*Disp) EditGetEnv

func (d *Disp) EditGetEnv(sid string) (map[string]string, error)

func (*Disp) Exists

func (d *Disp) Exists(db rpc.DB, sid string, path string) (bool, error)

NodeExists

func (*Disp) Expand

func (d *Disp) Expand(path string) (string, error)

func (*Disp) ExpandWithPrefix

func (d *Disp) ExpandWithPrefix(path, prefix string, pos int) (string, error)

Allow for the scenario where a user types 'tab' when the cursor is mid-word, eg 'set interfaces datadp0' with the cursor on the 'd' of 'dp0'. We want to return 'set interfaces dataplanedp0' in this case rather than an error.

<prefix> shows text up to cursor in the word in <path> indicated by the index <pos>. <path> takes format '[/]0/1/2/...' ie indexed from zero, and with optional leading '/'.

If <pos> < 0 then <prefix> will never be used, maintaining the original behaviour of the Expand() API.

func (*Disp) ExtractArchive

func (d *Disp) ExtractArchive(sid, revision, destination string) (string, error)

func (*Disp) Get

func (d *Disp) Get(db rpc.DB, sid string, path string) ([]string, error)

NodeGet

func (*Disp) GetCommitLog

func (d *Disp) GetCommitLog() (map[string]string, error)

func (*Disp) GetCompletions

func (d *Disp) GetCompletions(sid string, schema bool, path string) (map[string]string, error)

func (*Disp) GetConfigSystemFeatures

func (d *Disp) GetConfigSystemFeatures() (map[string]struct{}, error)

func (*Disp) GetDeviations

func (d *Disp) GetDeviations() (map[string]string, error)

func (*Disp) GetFeatures

func (d *Disp) GetFeatures() (map[string]string, error)

func (*Disp) GetHelp

func (d *Disp) GetHelp(sid string, schema bool, path string) (map[string]string, error)

func (*Disp) GetModuleSchemas

func (d *Disp) GetModuleSchemas() (string, error)

func (*Disp) GetSchemas

func (d *Disp) GetSchemas() (string, error)

func (*Disp) Load

func (d *Disp) Load(sid string, file string) (bool, error)

func (*Disp) LoadFrom

func (d *Disp) LoadFrom(sid, source, routingInstance string) (bool, error)

func (*Disp) LoadKeys

func (d *Disp) LoadKeys(sid, user, source, routingInstance string) (string, error)

LoadKeys RPC This provides the implementation for the "loadkey" cfgcli command

func (*Disp) LoadReportWarnings

func (d *Disp) LoadReportWarnings(sid string, file string) (bool, error)

func (*Disp) Merge

func (d *Disp) Merge(sid string, file string) (bool, error)

func (*Disp) MergeReportWarnings

func (d *Disp) MergeReportWarnings(sid string, file string) (bool, error)

func (*Disp) MigrateConfigFile

func (d *Disp) MigrateConfigFile(file string) (string, error)

func (*Disp) NodeGetComment

func (d *Disp) NodeGetComment(sid string, path string) (map[string]int, error)

func (*Disp) NodeGetCompleteEnv

func (d *Disp) NodeGetCompleteEnv(sid string, path string) (map[string]int, error)

func (*Disp) NodeGetStatus

func (d *Disp) NodeGetStatus(db rpc.DB, sid string, path string) (rpc.NodeStatus, error)

func (*Disp) NodeGetType

func (d *Disp) NodeGetType(sid string, path string) (rpc.NodeType, error)

func (*Disp) NodeIsDefault

func (d *Disp) NodeIsDefault(db rpc.DB, sid string, path string) (bool, error)

func (*Disp) ReadConfigFile

func (d *Disp) ReadConfigFile(file string) (string, error)

func (*Disp) ReadConfigFileRaw

func (d *Disp) ReadConfigFileRaw(file string) (string, error)

func (*Disp) Rename

func (d *Disp) Rename(sid string, fpath string, tpath string) (bool, error)

func (*Disp) Rollback

func (d *Disp) Rollback(sid, revision, comment string, debug bool) (string, error)

func (*Disp) Save

func (d *Disp) Save(_ string) (bool, error)

func (*Disp) SaveTo

func (d *Disp) SaveTo(dest, routingInstance string) (bool, error)

func (*Disp) SchemaGet

func (d *Disp) SchemaGet(modOrSubmod string, format string) (string, error)

func (*Disp) SessionChanged

func (d *Disp) SessionChanged(sid string) (bool, error)

func (*Disp) SessionExists

func (d *Disp) SessionExists(sid string) (bool, error)

func (*Disp) SessionGetEnv

func (d *Disp) SessionGetEnv(sid string) (map[string]string, error)

func (*Disp) SessionLock

func (d *Disp) SessionLock(sid string) (int32, error)

func (*Disp) SessionLocked

func (d *Disp) SessionLocked(sid string) (int32, error)

func (*Disp) SessionMarkSaved

func (d *Disp) SessionMarkSaved(sid string) (bool, error)

func (*Disp) SessionMarkUnsaved

func (d *Disp) SessionMarkUnsaved(sid string) (bool, error)

func (*Disp) SessionSaved

func (d *Disp) SessionSaved(sid string) (bool, error)

func (*Disp) SessionSetup

func (d *Disp) SessionSetup(sid string) (bool, error)

func (*Disp) SessionSetupShared

func (d *Disp) SessionSetupShared(sid string) (bool, error)

func (*Disp) SessionTeardown

func (d *Disp) SessionTeardown(sid string) (bool, error)

func (*Disp) SessionUnlock

func (d *Disp) SessionUnlock(sid string) (int32, error)

func (*Disp) Set

func (d *Disp) Set(sid string, path string) (string, error)

func (*Disp) SetConfigDebug

func (d *Disp) SetConfigDebug(sid, logName, level string) (string, error)

func (*Disp) Show

func (d *Disp) Show(db rpc.DB, sid string, path string, hideSecrets bool) (string, error)

func (*Disp) ShowConfigWithContextDiffs

func (d *Disp) ShowConfigWithContextDiffs(sid string, path string, showDefaults bool) (string, error)

func (*Disp) ShowDefaults

func (d *Disp) ShowDefaults(db rpc.DB, sid string, path string, hideSecrets bool) (string, error)

func (*Disp) TmplGet

func (d *Disp) TmplGet(path string) (map[string]string, error)

func (*Disp) TmplGetAllowed

func (d *Disp) TmplGetAllowed(sid, path string) ([]string, error)

func (*Disp) TmplGetChildren

func (d *Disp) TmplGetChildren(path string) ([]string, error)

func (*Disp) TmplValidatePath

func (d *Disp) TmplValidatePath(path string) (bool, error)

func (*Disp) TmplValidateValues

func (d *Disp) TmplValidateValues(path string) (bool, error)

func (*Disp) TreeGet

func (d *Disp) TreeGet(db rpc.DB, sid, path, encoding string, flags map[string]interface{}) (string, error)

func (*Disp) TreeGetFull

func (d *Disp) TreeGetFull(
	db rpc.DB, sid, path, encoding string,
	flags map[string]interface{},
) (string, error)

func (*Disp) TreeGetFullWithWarnings

func (d *Disp) TreeGetFullWithWarnings(
	db rpc.DB, sid, path, encoding string,
	flags map[string]interface{},
) (string, error, []error)

TreeGetFullWithWarnings - full tree including state, with any warnings. Warnings are non-fatal, eg a specific node's state function(s) may have failed, but we can still return overall state and config. Error indicates a non-existent path typically - something we shouldn't ignore.

func (*Disp) Validate

func (d *Disp) Validate(sid string) (string, error)

func (*Disp) ValidateConfig

func (d *Disp) ValidateConfig(sid, encoding, config string) (string, error)

func (*Disp) ValidatePath

func (d *Disp) ValidatePath(sid string, path string) (string, error)

type LoginPidError

type LoginPidError struct {
	// contains filtered or unexported fields
}

func (*LoginPidError) Error

func (e *LoginPidError) Error() string

type Srv

type Srv struct {
	*net.UnixListener

	Dlog    *log.Logger
	Elog    *log.Logger
	Wlog    *log.Logger
	Config  *configd.Config
	CompMgr schema.ComponentManager
	// contains filtered or unexported fields
}

func NewSrv

func NewSrv(
	l *net.UnixListener,
	ms, msFull schema.ModelSet,
	username string,
	config *configd.Config,
	elog *log.Logger,
	compMgr schema.ComponentManager,
) *Srv

func (*Srv) Log

func (d *Srv) Log(fmt string, v ...interface{})

Log is a common place to do logging so that the implementation may change in the future.

func (*Srv) LogError

func (d *Srv) LogError(err error)

LogError logs an error if the passed in value is non nil

func (*Srv) LogFatal

func (d *Srv) LogFatal(err error)

func (*Srv) NewConn

func (s *Srv) NewConn(conn *net.UnixConn) *SrvConn

NewConn creates a new SrvConn and returns a reference to it.

func (*Srv) Serve

func (s *Srv) Serve() error

Serve is the server main loop. It accepts connections and spawns a goroutine to handle that connection.

type SrvConn

type SrvConn struct {
	*net.UnixConn
	// contains filtered or unexported fields
}

func (*SrvConn) Call

func (conn *SrvConn) Call(
	disp *Disp,
	method string,
	args []interface{},
) (any, error)

func (*SrvConn) Handle

func (conn *SrvConn) Handle(compMgr schema.ComponentManager)

Handle is the main loop for a connection. It receives the requests, authorizes the request, calls the request method and returns the response to the client.

type VciRpcCaller

type VciRpcCaller interface {
	CallRpc(ctx *configd.Context, moduleName, rpcName, inputTreeJson string) (string, error)
}

Allows us to test without needing VCI DBUS infrastructure.

Jump to

Keyboard shortcuts

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