cs

package
v0.0.0-...-85119e8 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Config Session

Index

Constants

View Source
const MAX_HIST = 10

Variables

This section is empty.

Functions

func CreateCpHistEntry

func CreateCpHistEntry(cpName string, id string, user string, origin string, time int64) error

func DebugGetCSDB

func DebugGetCSDB() *db.DB

func DeleteCpConfig

func DeleteCpConfig(cpName string, user string) error

func LoadCpHistEntries

func LoadCpHistEntries(fileName string)

func SaveCpConfig

func SaveCpConfig(cpName string, user string) error

func UpdateCpHistFile

func UpdateCpHistFile(user string) error

Types

type CpHistEntries

type CpHistEntries struct {
	CpHistEntries []CpHistEntry `json:"cphistentries"`
}

func (*CpHistEntries) AddCpHistEntry

func (c *CpHistEntries) AddCpHistEntry(entry CpHistEntry)

func (*CpHistEntries) DeleteCpHistEntry

func (c *CpHistEntries) DeleteCpHistEntry(entry CpHistEntry)

func (*CpHistEntries) DeleteFirstCpHistEntry

func (c *CpHistEntries) DeleteFirstCpHistEntry()

type CpHistEntry

type CpHistEntry struct {
	Label  string `json:"label"`
	Id     string `json:"id"`
	User   string `json:"user"`
	Origin string `json:"origin"`
	Time   int64  `json:"time"`
}

type CsStatus

type CsStatus interface {
	Status() string
}

func Err2CsStatus

func Err2CsStatus(err error) CsStatus

type CsStatusAbortWarning

type CsStatusAbortWarning struct {
	UnlockFailure error // ConfigDB unlock failed
}

CsStatusAbortWarning indicates completion of CS Abort operation with warnings.

func (CsStatusAbortWarning) Status

func (s CsStatusAbortWarning) Status() string

type CsStatusCommitFailure

type CsStatusCommitFailure struct {
	Err error
}

func (CsStatusCommitFailure) Error

func (s CsStatusCommitFailure) Error() string

func (CsStatusCommitFailure) Status

func (s CsStatusCommitFailure) Status() string

type CsStatusCommitSuccess

type CsStatusCommitSuccess struct {
}

func (CsStatusCommitSuccess) Status

func (s CsStatusCommitSuccess) Status() string

type CsStatusCommitWarning

type CsStatusCommitWarning struct {
	UnlockFailure     error // ConfigDB unlock failed
	CheckpointFailure error // Checkpoint creation failed
}

CsStatusCommitWarning indicates completion of CS Commit operation with warnings.

func (CsStatusCommitWarning) Status

func (s CsStatusCommitWarning) Status() string

type CsStatusCreatedSession

type CsStatusCreatedSession struct {
}

func (CsStatusCreatedSession) Status

func (s CsStatusCreatedSession) Status() string

type CsStatusInternalError

type CsStatusInternalError struct {
	Err error
}

func (CsStatusInternalError) Error

func (s CsStatusInternalError) Error() string

func (CsStatusInternalError) Status

func (s CsStatusInternalError) Status() string

type CsStatusInvalidSession

type CsStatusInvalidSession struct {
	Tag ErrTag
}

CsStatusInvalidSession indicates session lookup failures or bad state. ErrTag holds the actual cause.

func (CsStatusInvalidSession) Error

func (s CsStatusInvalidSession) Error() string

func (CsStatusInvalidSession) Status

func (s CsStatusInvalidSession) Status() string

type CsStatusNotAllowed

type CsStatusNotAllowed struct {
}

CsStatusNotAllowed indicates user authorization error

func (CsStatusNotAllowed) Error

func (s CsStatusNotAllowed) Error() string

func (CsStatusNotAllowed) Status

func (s CsStatusNotAllowed) Status() string

type CsStatusResumedSession

type CsStatusResumedSession struct {
}

func (CsStatusResumedSession) Status

func (s CsStatusResumedSession) Status() string

type CsStatusSuccess

type CsStatusSuccess struct {
}

func (CsStatusSuccess) Status

func (s CsStatusSuccess) Status() string

type DSType

type DSType int
const (
	DSRunning DSType = iota

	DSCandidate  // Label (Session Token, except in Start Request)
	DSCheckpoint // Label (* in /etc/sonic/checkpoints/*.cp.json) (Future)
	DSFile       // Label (Arbitrary Filename *.json in the /etc dir) (Future)
)

type DataStore

type DataStore struct {
	Type  DSType
	Label string
}

func (*DataStore) Token

func (ds *DataStore) Token() string

Token returns the Label if Type is DSCandidate. Otherwise ""

type ErrTag

type ErrTag string
const (
	ErrTagNameNotFound    ErrTag = "cs-name-not-found"  // Lookup by name failed
	ErrTagTokenNotFound   ErrTag = "cs-token-not-found" // Lookup by token failed
	ErrTagInvalidUser     ErrTag = "cs-invalid-user"    // CS owned by someone else
	ErrTagInvalidTerminal ErrTag = "cs-invalid-term"    // CS active on different terminal
	ErrTagActive          ErrTag = "cs-active"          // Op not allowed on active CS
	ErrTagNotActive       ErrTag = "cs-inactive"        // Op not allowed on suspended CS
	ErrTagInvalidState    ErrTag = "cs-invalid-state"   // Op not allowed in current CS state
	ErrTagUnknown         ErrTag = "cs-unknown"         // Any unexpected CS context (mostly code error)
)

type GSOname

type GSOname struct {
}

GSOname option requires name to match.

type GSOstrict

type GSOstrict struct {
}

GSOstrict option requires session pid and username to match.

type GetSessionOpts

type GetSessionOpts interface {
}

type Session

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

func GetAllSessions

func GetAllSessions() ([]Session, error)

GetAllSessions returns all session info from cache

func GetSession

func GetSession(name string, token string, username string, roles []string,
	pid int32, opts ...GetSessionOpts) (Session, error)

func (*Session) Abort

func (sess *Session) Abort() (bool, CsStatus)

func (*Session) AbortTx

func (sess *Session) AbortTx(d *db.DB) error

func (*Session) Commit

func (sess *Session) Commit(label string,
	timeout int, confirm bool) (bool, CsStatus)

func (*Session) CommitTime

func (sess *Session) CommitTime() time.Time

CommitTime returns session commit timestamp

func (*Session) CommitTx

func (sess *Session) CommitTx(d *db.DB) error

func (*Session) Exit

func (sess *Session) Exit() (bool, CsStatus)

func (*Session) GetConfigDB

func (sess *Session) GetConfigDB(opts *db.Options) (*db.DB, bool, func(),
	error)

func (*Session) GetState

func (sess *Session) GetState() string

func (*Session) IsActive

func (sess *Session) IsActive() bool

IsActive returns true if this session is in active state

func (*Session) IsConfigSession

func (sess *Session) IsConfigSession() bool

func (*Session) IsPidActive

func (sess *Session) IsPidActive() bool

func (*Session) Kill

func (sess *Session) Kill(killActive bool, user string) CsStatus

func (*Session) LastActiveTime

func (sess *Session) LastActiveTime() time.Time

LastActiveTime returns timestamp of last activity on this session

func (*Session) LastExitTime

func (sess *Session) LastExitTime() time.Time

LastExitTime returns timestamp of last successful session exit event

func (*Session) LastResumeTime

func (sess *Session) LastResumeTime() time.Time

LastResumeTime returns timestamp of last successful session resume event

func (*Session) Name

func (sess *Session) Name() string

Name returns session name; or empty string for unnamed session

func (*Session) SendMesg

func (sess *Session) SendMesg(mesg string, userName string) error

func (*Session) SetCommitCh

func (cs *Session) SetCommitCh(ch chan<- bool)

func (*Session) SetCommitState

func (cs *Session) SetCommitState(state configSessionState)

func (*Session) SetRollbackCfg

func (cs *Session) SetRollbackCfg(cfg string)

func (*Session) StartCommitTimer

func (cs *Session) StartCommitTimer(timeout int) *time.Timer

func (*Session) StartOrResume

func (sess *Session) StartOrResume(pid int32) (string, bool, CsStatus)

func (*Session) StartTime

func (sess *Session) StartTime() time.Time

StartTime returns session creation timestamp.

func (*Session) StartTx

func (sess *Session) StartTx(d *db.DB, w []db.WatchKeys,
	tss []*db.TableSpec) error

func (*Session) String

func (sess *Session) String() string

func (*Session) TerminalPID

func (sess *Session) TerminalPID() int32

TerminalPID returns the active CLI terminal's pid; 0 if inactive

func (*Session) Token

func (sess *Session) Token() string

Token returns the unique id for this session

func (*Session) TxLen

func (sess *Session) TxLen() int

TxLen returns the number of redis operations cached in this session

func (*Session) UpdateLastActiveTime

func (cs *Session) UpdateLastActiveTime()

func (*Session) Username

func (sess *Session) Username() string

Username returns the user who created this session

Jump to

Keyboard shortcuts

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