gnmi

package
v0.0.0-...-1510907 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2023 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const ENABLE_NATIVE_WRITE = false
View Source
const ENABLE_TRANSLIB_WRITE = false

Variables

View Source
var (
	JwtRefreshInt time.Duration
	JwtValidInt   time.Duration
)
View Source
var AuthLock sync.Mutex

Functions

func BasicAuthenAndAuthor

func BasicAuthenAndAuthor(ctx context.Context) (context.Context, error)

func ClientCertAuthenAndAuthor

func ClientCertAuthenAndAuthor(ctx context.Context) (context.Context, error)

func GenerateJwtSecretKey

func GenerateJwtSecretKey()

func GetUserRoles

func GetUserRoles(usr *user.User) ([]string, error)

func IsNativeOrigin

func IsNativeOrigin(origin string) bool

func JwtAuthenAndAuthor

func JwtAuthenAndAuthor(ctx context.Context) (*spb.JwtToken, context.Context, error)

func PAMAuthUser

func PAMAuthUser(u string, p string) error

func ParseOrigin

func ParseOrigin(paths []*gnmipb.Path) (string, error)

func PopulateAuthStruct

func PopulateAuthStruct(username string, auth *common_utils.AuthInfo, r []string) error

func RebootSystem

func RebootSystem(fileName string) error

func UserPwAuth

func UserPwAuth(username string, passwd string) (bool, error)

Types

type AuthTypes

type AuthTypes map[string]bool

func (AuthTypes) Any

func (i AuthTypes) Any() bool

func (AuthTypes) Enabled

func (i AuthTypes) Enabled(mode string) bool

func (AuthTypes) Set

func (i AuthTypes) Set(mode string) error

func (AuthTypes) String

func (i AuthTypes) String() string

func (AuthTypes) Unset

func (i AuthTypes) Unset(mode string) error

type Claims

type Claims struct {
	Username string   `json:"username"`
	Roles    []string `json:"roles"`
	jwt.StandardClaims
}

type Client

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

Client contains information about a subscribe client that has connected to the server.

func NewClient

func NewClient(addr net.Addr) *Client

NewClient returns a new initialized client.

func (*Client) Close

func (c *Client) Close()

Closing of client queue is triggered upon end of stream receive or stream error or fatal error of any client go routine . it will cause cancle of client context and exit of the send goroutines.

func (*Client) Run

func (c *Client) Run(stream gnmipb.GNMI_SubscribeServer) (err error)

Run starts the subscribe client. The first message received must be a SubscriptionList. Once the client is started, it will run until the stream is closed or the schedule completes. For Poll queries the Run will block internally after sync until a Poll request is made to the server.

func (*Client) String

func (c *Client) String() string

String returns the target the client is querying.

type Config

type Config struct {
	// Port for the Server to listen on. If 0 or unset the Server will pick a port
	// for this Server.
	Port                int64
	LogLevel            int
	Threshold           int
	UserAuth            AuthTypes
	EnableTranslibWrite bool
	EnableNativeWrite   bool
	IdleConnDuration    int
}

Config is a collection of values for Server

type ConnectionManager

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

func (*ConnectionManager) Add

func (cm *ConnectionManager) Add(addr net.Addr, query string) (string, bool)

func (*ConnectionManager) GetThreshold

func (cm *ConnectionManager) GetThreshold() int

func (*ConnectionManager) PrepareRedis

func (cm *ConnectionManager) PrepareRedis()

func (*ConnectionManager) Remove

func (cm *ConnectionManager) Remove(key string) bool

type Credentials

type Credentials struct {
	Password string `json:"password"`
	Username string `json:"username"`
}

type Server

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

Server manages a single gNMI Server implementation. Each client that connects via Subscribe or Get will receive a stream of updates based on the requested path. Set request is processed by server too.

func NewServer

func NewServer(config *Config, opts []grpc.ServerOption) (*Server, error)

New returns an initialized Server.

func (*Server) Address

func (srv *Server) Address() string

Address returns the port the Server is listening to.

func (*Server) Authenticate

func (*Server) CancelReboot

TODO: Support GNOI CancelReboot

func (*Server) Capabilities

func (*Server) ClearNeighbors

func (srv *Server) ClearNeighbors(ctx context.Context, req *spb.ClearNeighborsRequest) (*spb.ClearNeighborsResponse, error)

func (*Server) CopyConfig

func (srv *Server) CopyConfig(ctx context.Context, req *spb.CopyConfigRequest) (*spb.CopyConfigResponse, error)

func (*Server) Get

Get implements the Get RPC in gNMI spec.

func (*Server) ImageDefault

func (srv *Server) ImageDefault(ctx context.Context, req *spb.ImageDefaultRequest) (*spb.ImageDefaultResponse, error)

func (*Server) ImageInstall

func (srv *Server) ImageInstall(ctx context.Context, req *spb.ImageInstallRequest) (*spb.ImageInstallResponse, error)

func (*Server) ImageRemove

func (srv *Server) ImageRemove(ctx context.Context, req *spb.ImageRemoveRequest) (*spb.ImageRemoveResponse, error)

func (*Server) Ping

func (*Server) Port

func (srv *Server) Port() int64

Port returns the port the Server is listening to.

func (*Server) Reboot

func (*Server) RebootStatus

TODO: Support GNOI RebootStatus

func (*Server) Refresh

func (*Server) Serve

func (srv *Server) Serve() error

Serve will start the Server serving and block until closed.

func (*Server) Set

func (*Server) SetPackage

func (srv *Server) SetPackage(rs gnoi_system_pb.System_SetPackageServer) error

func (*Server) ShowTechsupport

func (srv *Server) ShowTechsupport(ctx context.Context, req *spb.TechsupportRequest) (*spb.TechsupportResponse, error)

func (*Server) Subscribe

func (s *Server) Subscribe(stream gnmipb.GNMI_SubscribeServer) error

Subscribe implements the gNMI Subscribe RPC.

func (*Server) Time

type UserCredential

type UserCredential struct {
	Username string
	Password string
}

func (UserCredential) PAMAuthenticate

func (u UserCredential) PAMAuthenticate() error

PAMAuthenticate performs PAM authentication for the user credentials provided

func (UserCredential) PAMConvHandler

func (u UserCredential) PAMConvHandler(s pam.Style, msg string) (string, error)

PAM conversation handler.

Jump to

Keyboard shortcuts

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