Documentation ¶
Index ¶
- func GetAddressOption(optionName string, options map[string]string) (string, error)
- func GetBoolOption(optionName string, options map[string]string) (bool, error)
- func GetDurationOption(optionName string, options map[string]string) (time.Duration, error)
- func GetIntOption(optionName string, options map[string]string) (int, error)
- func GetPortOption(optionName string, options map[string]string) (string, error)
- func GetStringListOption(optionName string, options map[string]string) ([]string, error)
- func GetStringOption(optionName string, options map[string]string) (string, error)
- func IsBadConfigError(err error) bool
- func NewBadConfigError(err error) error
- func NewBadConfigErrorf(msg string, args ...interface{}) error
- func NewInventoryService(inventory Inventory) gen.DeviceInventoryServer
- func OptionHelp(deviceName string) (map[string]string, error)
- func PackageFile(file string) string
- func Register(name string, creator Creator, options map[string]Option)
- func Registered() (keys []string)
- func SanitizedOptions(options map[string]Option, config map[string]string) (map[string]string, error)
- func Unregister(name string)
- func WriteConfigs(configPath string, configs []*Config) error
- type ClusterClock
- type Config
- type Creator
- type CredentialResolver
- type Device
- type GRPCConnector
- type GRPCConnectorConfig
- type Info
- type Inventory
- type InventoryOption
- func WithClientFactory(f func(gnmi.GNMIClient, *Info) cvclient.CVClient) InventoryOption
- func WithGNMIClient(c gnmi.GNMIClient) InventoryOption
- func WithGRPCConn(c *grpc.ClientConn) InventoryOption
- func WithGRPCConnector(c GRPCConnector) InventoryOption
- func WithGRPCServerAddr(addr string) InventoryOption
- func WithStandaloneStatus(standalone bool) InventoryOption
- type ManagedDeviceStatus
- type Manager
- type MetricTracker
- type Option
- type Sensor
- type SensorConfig
- type SensorOption
- func WithLimitDatasourcesToRun(limit int) SensorOption
- func WithMetricTracker(metricTracker MetricTracker) SensorOption
- func WithSensorClientFactory(f func(gnmi.GNMIClient, *Info) cvclient.CVClient) SensorOption
- func WithSensorClusterClock(c ClusterClock) SensorOption
- func WithSensorConfigChan(configCh chan *Config) SensorOption
- func WithSensorConnector(c GRPCConnector) SensorOption
- func WithSensorConnectorAddress(addr string) SensorOption
- func WithSensorCredentialResolver(c CredentialResolver) SensorOption
- func WithSensorFailureRetryBackoffBase(d time.Duration) SensorOption
- func WithSensorFailureRetryBackoffMax(d time.Duration) SensorOption
- func WithSensorGNMIClient(c gnmi.GNMIClient) SensorOption
- func WithSensorGRPCConn(c *grpc.ClientConn) SensorOption
- func WithSensorHeartbeatInterval(d time.Duration) SensorOption
- func WithSensorHostname(hostname string) SensorOption
- func WithSensorIP(ip string) SensorOption
- func WithSensorMaxClockDelta(d time.Duration) SensorOption
- func WithSensorMetricIntervalTime(d time.Duration) SensorOption
- func WithSensorSkipSubscribe(skipSubscribe bool) SensorOption
- func WithSensorStandaloneStatus(standalone bool) SensorOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAddressOption ¶
GetAddressOption returns the option specified by optionName as a validated IP address or hostname.
func GetBoolOption ¶
GetBoolOption returns the option specified by optionName as a boolean.
func GetDurationOption ¶
GetDurationOption returns the option specified by optionName as a time.Duration.
func GetIntOption ¶
GetIntOption returns the option specified by optionName as an int.
func GetPortOption ¶
GetPortOption returns the option specified by optionName as a validated port number.
func GetStringListOption ¶
GetStringListOption returns the option specified by optionName as a string slice.
func GetStringOption ¶
GetStringOption returns the option specified by optionName as a string.
func IsBadConfigError ¶
IsBadConfigError check if given errors is a bad configuration error.
func NewBadConfigError ¶
NewBadConfigError returns a BadConfigError
func NewBadConfigErrorf ¶
NewBadConfigErrorf returns a BadConfigError
func NewInventoryService ¶
func NewInventoryService(inventory Inventory) gen.DeviceInventoryServer
NewInventoryService returns a protobuf DeviceInventoryServer from an Inventory.
func OptionHelp ¶
OptionHelp returns the options and associated help strings of the specified device.
func PackageFile ¶
PackageFile will find the last package and filename. Example: my/package/here/file.go -> here/file.go
func Registered ¶
func Registered() (keys []string)
Registered returns a list of registered device names.
func SanitizedOptions ¶
func SanitizedOptions(options map[string]Option, config map[string]string) (map[string]string, error)
SanitizedOptions takes the map of device option keys and values passed in at the command line and checks it against the device or manager's exported list of accepted options, returning an error if there are inappropriate or missing options.
func WriteConfigs ¶
WriteConfigs writes a list of Config to the specified path.
Types ¶
type ClusterClock ¶
type ClusterClock interface { // clock channel created using below function is expected to be closed, // in case of any failures SubscribeToClusterClock(ctx context.Context, conn grpc.ClientConnInterface) (chan time.Time, error) }
ClusterClock is the interface used to implement clock sync logic.
type Config ¶
type Config struct { Name string `yaml:"Name,omitempty"` Device string `yaml:"Device,omitempty"` NoStream bool `yaml:"NoStream,omitempty"` Options map[string]string `yaml:"Options,omitempty"` LogLevel string `yaml:"LogLevel,omitempty"` Credentials map[string]string `yaml:"Credentials,omitempty"` Enabled bool `yaml:"Enabled,omitempty"` ForceUpdate int64 `yaml:"ForceUpdate,omitempty"` // contains filtered or unexported fields }
Config represents a single device configuration.
func NewDeletedConfig ¶
NewDeletedConfig creates a config that indicates a deleted device config.
func NewSyncEndConfig ¶
func NewSyncEndConfig() *Config
NewSyncEndConfig creates a new config that represents the end of the sync phase
func ReadConfigs ¶
ReadConfigs generates device configs from the config file at the specified path.
type CredentialResolver ¶
CredentialResolver is the interface used to resolve credentials.
type Device ¶
type Device interface { Alive(ctx context.Context) (bool, error) DeviceID(ctx context.Context) (string, error) Providers() ([]provider.Provider, error) // Type should return the type of the device. The returned // values should be one of the constants defined for the purpose // in the cvclient/v2 package such as VirtualSwitch etc. // If this method returns an empty string, a default value // (NetworkElement) is used. Type() string // IPAddr should return the management IP address of the device. // Return "" if this is not known. IPAddr(ctx context.Context) (string, error) }
A Device knows how to interact with a specific device.
type GRPCConnector ¶
type GRPCConnector interface { Connect(ctx context.Context, conn *grpc.ClientConn, addr string, config GRPCConnectorConfig) (*grpc.ClientConn, error) }
GRPCConnector allows callers to supply one gRPC connection and to create another to be used by a device implementation
func NewDefaultGRPCConnector ¶
func NewDefaultGRPCConnector() GRPCConnector
NewDefaultGRPCConnector return empty object
type GRPCConnectorConfig ¶
GRPCConnectorConfig used to pass configuration parameters to GRPCConnector interface
type Info ¶
type Info struct { ID string Context context.Context Device Device Config *Config Status ManagedDeviceStatus }
Info contains the running state of an instantiated device.
func NewDeviceInfo ¶
NewDeviceInfo takes a device config, creates the device, and returns an device Info.
type Inventory ¶
type Inventory interface { Add(deviceInfo *Info) error Delete(key string) error Get(key string) (*Info, error) List() []*Info SetStatus(key string, status ManagedDeviceStatus) error }
An Inventory maintains a set of devices.
func NewInventory ¶
func NewInventory(ctx context.Context, gnmiClient gnmi.GNMIClient, clientFactory func(gnmi.GNMIClient, *Info) cvclient.CVClient) Inventory
NewInventory creates an Inventory. Deprecated: Use NewInventoryWithOptions instead.
func NewInventoryWithOptions ¶
func NewInventoryWithOptions(ctx context.Context, options ...InventoryOption) Inventory
NewInventoryWithOptions creates an Inventory with the supplied options.
type InventoryOption ¶
type InventoryOption func(*inventory)
InventoryOption configures how we create the Inventory.
func WithClientFactory ¶
func WithClientFactory( f func(gnmi.GNMIClient, *Info) cvclient.CVClient) InventoryOption
WithClientFactory sets a client factory on the Inventory.
func WithGNMIClient ¶
func WithGNMIClient(c gnmi.GNMIClient) InventoryOption
WithGNMIClient sets a gNMI client on the Inventory.
func WithGRPCConn ¶
func WithGRPCConn(c *grpc.ClientConn) InventoryOption
WithGRPCConn sets a gRPC connection on the Inventory.
func WithGRPCConnector ¶
func WithGRPCConnector(c GRPCConnector) InventoryOption
WithGRPCConnector sets a gRPC connector on the Inventory.
func WithGRPCServerAddr ¶
func WithGRPCServerAddr(addr string) InventoryOption
WithGRPCServerAddr sets an grpc server address on the Inventory.
func WithStandaloneStatus ¶
func WithStandaloneStatus(standalone bool) InventoryOption
WithStandaloneStatus sets flag to identify if its standalone sensor
type ManagedDeviceStatus ¶
type ManagedDeviceStatus string
ManagedDeviceStatus contains the status of a managed device.
var ( // StatusActive indicates that a device is active. StatusActive ManagedDeviceStatus = "DEVICE_STATUS_ACTIVE" // StatusInactive indicates that a device is inactive, should // still be tracked by CloudVision. StatusInactive ManagedDeviceStatus = "DEVICE_STATUS_INACTIVE" // StatusRemoved indicates that a device should no longer // be tracked by CloudVision. StatusRemoved ManagedDeviceStatus = "DEVICE_STATUS_REMOVED" )
type MetricTracker ¶
type MetricTracker interface { // TrackDatasources tracks how many unique datasources exist in the sensor TrackDatasources(ctx context.Context, numDatasource int) // TrackDatasourceErrors tracks how many errors the datasources encounter. This metric is // partitioned by the type of the datasource and the error. This metric is monotonically // increasing TrackDatasourceErrors(ctx context.Context, typ string, errorType string) // TrackDatasourceDeploys tracks how often datasources of a particular type are deployed. // This metric is monotonically increasing TrackDatasourceDeploys(ctx context.Context, typ string) // TrackDatasourceRestarts tracks how often datasources of a particular type are restarted. // This metric is monotonically increasing TrackDatasourceRestarts(ctx context.Context, typ string) }
MetricTracker tracks various metrics for datasources.
type Sensor ¶
type Sensor struct {
// contains filtered or unexported fields
}
Sensor manages the config for multiple datasources
type SensorConfig ¶
type SensorConfig struct { Connector GRPCConnector // Receives the grpcServer connection and returns a CredentialResolver. CredResolverCreator func(conn *grpc.ClientConn) (CredentialResolver, error) //Receives the grpc connection and returns a ClusterClock ClusterClockCreator func(conn *grpc.ClientConn) (ClusterClock, error) }
SensorConfig to store GRPCConnector config
type SensorOption ¶
type SensorOption func(m *Sensor)
SensorOption is used to configure the Sensor.
func WithLimitDatasourcesToRun ¶
func WithLimitDatasourcesToRun(limit int) SensorOption
WithLimitDatasourcesToRun limits the number of datasources that can be run at any given time in the sensor. The datasources that are run are random. If a datasources is stopped/deleted once we hit the limit, an arbitary one will be chosen to run in its place.
func WithMetricTracker ¶
func WithMetricTracker(metricTracker MetricTracker) SensorOption
WithMetricTracker adds a metric tracker to the sensor to track metrics
func WithSensorClientFactory ¶
func WithSensorClientFactory(f func(gnmi.GNMIClient, *Info) cvclient.CVClient) SensorOption
WithSensorClientFactory sets a cvclient factory on the Sensor.
func WithSensorClusterClock ¶
func WithSensorClusterClock(c ClusterClock) SensorOption
WithSensorClusterClock sets a cluster clock object.
func WithSensorConfigChan ¶
func WithSensorConfigChan(configCh chan *Config) SensorOption
WithSensorConfigChan provides a channel for supplying configs to the sensor
func WithSensorConnector ¶
func WithSensorConnector(c GRPCConnector) SensorOption
WithSensorConnector sets a gRPC connector.
func WithSensorConnectorAddress ¶
func WithSensorConnectorAddress(addr string) SensorOption
WithSensorConnectorAddress sets the connector address.
func WithSensorCredentialResolver ¶
func WithSensorCredentialResolver(c CredentialResolver) SensorOption
WithSensorCredentialResolver sets a credential resolver.
func WithSensorFailureRetryBackoffBase ¶
func WithSensorFailureRetryBackoffBase(d time.Duration) SensorOption
WithSensorFailureRetryBackoffBase sets the duration between datasource restarts on failure.
func WithSensorFailureRetryBackoffMax ¶
func WithSensorFailureRetryBackoffMax(d time.Duration) SensorOption
WithSensorFailureRetryBackoffMax sets the max backoff between datasource restarts due to failures.
func WithSensorGNMIClient ¶
func WithSensorGNMIClient(c gnmi.GNMIClient) SensorOption
WithSensorGNMIClient sets a gNMI client on the Sensor.
func WithSensorGRPCConn ¶
func WithSensorGRPCConn(c *grpc.ClientConn) SensorOption
WithSensorGRPCConn sets a gRPC connection on the Sensor.
func WithSensorHeartbeatInterval ¶
func WithSensorHeartbeatInterval(d time.Duration) SensorOption
WithSensorHeartbeatInterval sets the duration between sensor heartbeats.
func WithSensorHostname ¶
func WithSensorHostname(hostname string) SensorOption
WithSensorHostname sets the the hostname of the Sensor.
func WithSensorIP ¶
func WithSensorIP(ip string) SensorOption
WithSensorIP sets the the IP of the Sensor.
func WithSensorMaxClockDelta ¶
func WithSensorMaxClockDelta(d time.Duration) SensorOption
WithSensorMaxClockDelta sets the time delta allowed between sensor and server clock
func WithSensorMetricIntervalTime ¶
func WithSensorMetricIntervalTime(d time.Duration) SensorOption
WithSensorMetricIntervalTime sets the interval time used to send metrics to server
func WithSensorSkipSubscribe ¶
func WithSensorSkipSubscribe(skipSubscribe bool) SensorOption
WithSensorSkipSubscribe determines whether we skip subscribing for datasource configurations
func WithSensorStandaloneStatus ¶
func WithSensorStandaloneStatus(standalone bool) SensorOption
WithSensorStandaloneStatus sets the stanalone status.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package cvclient defines an interface for connecting to and communicating with CloudVision.
|
Package cvclient defines an interface for connecting to and communicating with CloudVision. |
mock
Package mock is a generated GoMock package.
|
Package mock is a generated GoMock package. |
v1
Package v1 implements the version v1 client for communicating with CloudVision.
|
Package v1 implements the version v1 client for communicating with CloudVision. |
v2
Package v2 implements the v2 protocol for communicating with CloudVision.
|
Package v2 implements the v2 protocol for communicating with CloudVision. |
Package mock is a generated GoMock package.
|
Package mock is a generated GoMock package. |