sim

package
v0.7.12 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckErrors

func CheckErrors(errChan chan error) error

func Connect

func Connect(
	_ context.Context,
	address string,
	caPath, certPath, keyPath string,
	insec bool,
	opts ...grpc.DialOption,
) (*grpc.ClientConn, error)

connect creates a gRPC connection to a server.

func IntToInt16

func IntToInt16(i int) (int16, error)

IntToint16 safely converts int to int16. This is needed for 64bit systems where int is defined as a 64bit integer. Returns an error when the value is out of the range.

func LoadFile

func LoadFile(filePath string) (string, error)

func NewIFMSimService

func NewIFMSimService(nodeStore Store, cfg *Config) northbound.Service

NewService returns a new model Service.

func NewUUID

func NewUUID(enUUID string) (string, error)

NewUUID returns the locally unique UUID for the edge node.

Types

type Cli

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

func NewCli

func NewCli(ctx context.Context, client Client, cfg *CliCfg) *Cli

func (*Cli) PromptNodeCreate

func (c *Cli) PromptNodeCreate(_ interface{}) (interface{}, error)

func (*Cli) PromptNodeCreateMany

func (c *Cli) PromptNodeCreateMany(_ interface{}) (interface{}, error)

func (*Cli) PromptNodeDelete

func (c *Cli) PromptNodeDelete(arg interface{}) (interface{}, error)

func (*Cli) PromptNodeDeleteMany

func (c *Cli) PromptNodeDeleteMany(arg interface{}) (interface{}, error)

func (*Cli) PromptNodeGet

func (c *Cli) PromptNodeGet(arg interface{}) (interface{}, error)

func (*Cli) PromptNodeList

func (c *Cli) PromptNodeList(_ interface{}) (interface{}, error)

func (*Cli) PromptRoot

func (c *Cli) PromptRoot() (interface{}, error)

type CliCfg

type CliCfg struct {
	Project         string
	OnboardUsername string
	OnboardPassword string
	APIUsername     string
	APIPassword     string
	EnableNIO       bool
	EnableTeardown  bool
}

type Client

type Client interface {
	Create(context.Context, string, *ensimapi.NodeCredentials, bool) error
	// CreateNodes creates a number of nodes with the given credentials and teardown option.
	// number is the total number of nodes to create, and batch is the number of nodes to create in each batch.
	CreateNodes(context.Context, uint32, uint32, *ensimapi.NodeCredentials, bool) error
	DeleteNodes(context.Context, uint32) error
	Update(context.Context, string, map[ensimapi.AgentType]ensimapi.AgentState) error
	Get(context.Context, string) (*ensimapi.Node, error)
	List(context.Context) ([]*ensimapi.Node, error)
	Delete(context.Context, string) error
	Close() error
}

func NewClient

func NewClient(ctx context.Context, address string) (Client, error)

type Config

type Config struct {
	CAPath                string
	KeyPath               string
	CertPath              string
	GRPCPort              int16
	OrchFQDN              string
	OrchIP                string
	OrchCAPath            string
	BaseFolder            string
	OamServerAddr         string
	EnableDownloads       bool
	URLFilesRS            string
	TinkerActionsVersion  string
	AgentsManifestVersion string
	TiberOSVersion        string
}

func Cfg

func Cfg() (*Config, error)

type EdgeNode

type EdgeNode struct {
	UUID
	// contains filtered or unexported fields
}

func NewEdgeNode

func NewEdgeNode(cfg *defs.Settings) *EdgeNode

func (*EdgeNode) GetAgentsStates

func (en *EdgeNode) GetAgentsStates() ensim_agents.StateMap

func (*EdgeNode) GetAgentsStatus

func (en *EdgeNode) GetAgentsStatus() map[ensimapi.StatusSource]*ensimapi.NodeStatus

func (*EdgeNode) SetAgentsStates

func (en *EdgeNode) SetAgentsStates(states map[ensim_agents.AgentType]ensim_agents.AgentState)

func (*EdgeNode) Start

func (en *EdgeNode) Start() error

func (*EdgeNode) StatsCollector

func (en *EdgeNode) StatsCollector()

func (*EdgeNode) Stop

func (en *EdgeNode) Stop() error

type EdgeNodes

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

EdgeNodes data structure for storing EdgeNode.

func (*EdgeNodes) Add

func (s *EdgeNodes) Add(en *EdgeNode) error

Add adds the specified edge-node.

func (*EdgeNodes) Get

func (s *EdgeNodes) Get(id UUID) (*EdgeNode, error)

Get returns the edge-node with the specified UUID.

func (*EdgeNodes) Len

func (s *EdgeNodes) Len() (int, error)

Len number of edgeNodes.

func (*EdgeNodes) List

func (s *EdgeNodes) List() ([]*EdgeNode, error)

List returns slice containing all current edgeNodes.

func (*EdgeNodes) Remove

func (s *EdgeNodes) Remove(id UUID) error

Remove removes the specified edge-node.

func (*EdgeNodes) Watch

func (s *EdgeNodes) Watch(ctx context.Context, ch chan<- Event, options ...WatchOptions) error

type Event

type Event struct {
	Key   interface{}
	Value interface{}
	Type  interface{}
}

Event store event data structure.

type EventChannel

type EventChannel chan Event

EventChannel is a channel which can accept an Event.

type Manager

type Manager interface {
	Start() error
	Stop() error
}

func NewManager

func NewManager(cfg *Config) (Manager, error)

type NodeEvent

type NodeEvent int

NodeEvent a node event.

const (
	// None non node event.
	None NodeEvent = iota
	// Created created node event.
	Created
	// Updated updated node event.
	Updated
	// Deleted deleted  node event.
	Deleted
)

func (NodeEvent) String

func (e NodeEvent) String() string

String converts node event to string.

type Server

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

Server implements the TrafficSim gRPC service for administrative facilities.

func (*Server) CreateNode

func (*Server) CreateNodes

func (*Server) DeleteNode

func (*Server) DeleteNodes

func (*Server) GetNode

func (*Server) UpdateNode

type Service

type Service struct {
	northbound.Service
	// contains filtered or unexported fields
}

Service is a Service implementation for administration.

func (*Service) Register

func (s *Service) Register(r *grpc.Server)

Register registers the TrafficSim Service with the gRPC server.

type Store

type Store interface {
	// Add   adds the specified edge-node
	Add(en *EdgeNode) error
	// Remove removes the specified edge-node
	Remove(id UUID) error
	// Get gets a edge-node based on a given UUID
	Get(id UUID) (*EdgeNode, error)
	// List lists edgeNodes
	List() ([]*EdgeNode, error)
	// Len number of edgeNodes
	Len() (int, error)

	// Watch watches the node inventory events using the supplied channel
	Watch(ctx context.Context, ch chan<- Event, options ...WatchOptions) error
}

Store store interface.

func NewStore

func NewStore() Store

NewStore creates a new edge-node store.

type UUID

type UUID string

UUID is an alias for string subscription UUID.

type WatchOptions

type WatchOptions struct {
	Replay  bool
	Monitor bool
}

WatchOptions allows tailoring the WatchNodes behavior.

type Watcher

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

Watcher event watcher.

type Watchers

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

Watchers stores the information about watchers.

func NewWatchers

func NewWatchers() *Watchers

NewWatchers creates watchers.

func (*Watchers) AddWatcher

func (ws *Watchers) AddWatcher(id uuid.UUID, ch chan<- Event) error

AddWatcher adds a watcher.

func (*Watchers) RemoveWatcher

func (ws *Watchers) RemoveWatcher(id uuid.UUID) error

RemoveWatcher removes a watcher.

func (*Watchers) Send

func (ws *Watchers) Send(event Event)

Send sends an event for all registered watchers.

Jump to

Keyboard shortcuts

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