lemming

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: Apache-2.0 Imports: 21 Imported by: 1

README

Lemming the Openconfig reference device implementation

Purpose

To provide a reference implementation of a device which provides the collection of customers APIs used for Openconfig. This includes:

  • gNMI
  • gNOI
  • gRIBI
  • P4RT
  • BGP
  • ISIS

to clearly and authoritatively specify the expected behavior of an OpenConfig-compliant device, and to aid in its test development and debugging. Anyone can use this reference implementation to quickly write device tests independent of the availability of a real and compliant implementation. The reference can also be used to augment the consumer contract when a fake-derived test suite is delivered to network device vendors, serving as a tool for consensus in the device-implementor <-> device-consumer relationship.

Running the Fake gNMI Server

go run ./cmd/lemming --zapi_addr unix:/tmp/zserv.api --alsologtostderr

Wait for the message "lemming initialization complete".
This might take a minute the first time to compile the large generated code.

Install gnmic: https://gnmic.openconfig.net/

// SetRequest configuring hostname
gnmic -a localhost:9339 --insecure -u foo -p bar --target fakedut set --update-path openconfig:/system/config/hostname --update-value rosesarered -e json_ietf

// SubscribeRequest/ONCE getting configured hostname
gnmic -a localhost:9339 --insecure -u foo -p bar --target fakedut subscribe --mode once --path openconfig:/system/config/hostname

// SubscribeRequest/ONCE getting hostname reflected as system state
gnmic -a localhost:9339 --insecure -u foo -p bar --target fakedut subscribe --mode once --path openconfig:/system/state/hostname

Running integration tests

Prerequisites:

  • KNE setup and cluster deployed

Deploy and Test:

  • Optional: Build and load lemming container from source: make load
  • Run integration tests: go test ./integration_tests/...

Debugging Lemming

  1. Load the debug image in the cluster: make load-debug
  2. Modify a topology.pb.txt to start lemming with dlv.
nodes: {
    name: "lemming"
    vendor: OPENCONFIG
    config: {
        command: "/dlv/dlv"
        args: "exec"
        args: "--headless"
        args: "--continue"
        args: "--accept-multiclient"
        args: "--listen=:56268"
        args: "--api-version=2"
        args: "/lemming/lemming"
        args: "--"
    }
}
  1. Create the topology: kne create <topofile>.
  2. Forward the debugger connection (this is blocking so run in seperate terminal): kubectl port-forward -n <topo name> <node name> 56268:56268
  3. Attach to the debugger.
    1. Using VS Code: Run and Debug -> Connect to server
    2. Using dlv cli: dlv connect localhost:56268
      1. Required: Configure subsitute-path so dlv can resolve source code: config substitute-path /build <abs path to lemming src>

Documentation

Overview

Package lemming provides reference device to be used with ondatra.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

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

Device is the reference device implementation.

func New

func New(targetName, zapiURL string, opts ...Option) (*Device, error)

New returns a new initialized device.

func (*Device) GNMI

func (d *Device) GNMI() *fgnmi.Server

GNMI returns the gNMI server implementation.

func (*Device) GNMIAddr added in v0.2.0

func (d *Device) GNMIAddr() string

GNMIAddr returns the address that the gNMI/gNOI/gNSI server is listening on.

func (*Device) GNMIListener added in v0.2.0

func (d *Device) GNMIListener() net.Listener

GNMIListener returns the listener that the gNMI/gNOI/gNSI server is listening on.

func (*Device) GNSI

func (d *Device) GNSI() *fgnsi.Server

GNSI returns the gNSI server implementation.

func (*Device) GRIBIAddr added in v0.2.0

func (d *Device) GRIBIAddr() string

GRIBIAddr returns the address that the gRIBI server is listening on.

func (*Device) GRIBIListener added in v0.2.0

func (d *Device) GRIBIListener() net.Listener

GRIBIListener returns the listener that the gRIBI server is listening on.

func (*Device) P4RTAddr added in v0.2.0

func (d *Device) P4RTAddr() string

P4RTAddr returns the address that the P4RT server is listening on.

func (*Device) P4RTListener added in v0.2.0

func (d *Device) P4RTListener() net.Listener

P4RTListener returns the listener that the P4RT server is listening on.

func (*Device) Stop

func (d *Device) Stop() error

Stop stops the listening services. If error is not nil, it will contain why the server failed.

type Option added in v0.2.0

type Option func(*opt)

Option are device startup options for lemming.

func WithGNMIAddr added in v0.2.0

func WithGNMIAddr(addr string) Option

WithGNMIAddr is a device option that specifies that the gRIBI address.

func WithGRIBIAddr added in v0.2.0

func WithGRIBIAddr(addr string) Option

WithGRIBIAddr is a device option that specifies that the gRIBI address.

func WithInitialConfig added in v0.2.0

func WithInitialConfig(c []byte) Option

WithInitialConfig sets the startup config of the device to c. Today we do not allow the configuration to be changed in flight, but this can be implemented in the future.

This option is intended for standalone device testing.

func WithP4RTAddr added in v0.2.0

func WithP4RTAddr(addr string) Option

WithP4RTAddr is a device option that specifies that the P4RT address.

func WithTLSCredsFromFile added in v0.2.0

func WithTLSCredsFromFile(certFile, keyFile string) (Option, error)

WithTLSCredsFromFile loads the credentials from the specified cert and key file and returns them such that they can be used for the gNMI and gRIBI servers.

func WithTransportCreds added in v0.2.0

func WithTransportCreds(c credentials.TransportCredentials) Option

WithTransportCreds returns a wrapper of TransportCredentials into a DevOpt.

Directories

Path Synopsis
Package bgp contains a BGP implementation (using GoBGP) whose API is OpenConfig.
Package bgp contains a BGP implementation (using GoBGP) whose API is OpenConfig.
cmd
decodepacket
Package main takes a packet hex string and prints the decoded packet.
Package main takes a packet hex string and prints the decoded packet.
printpcap
Package main dumps a PCAP file.
Package main dumps a PCAP file.
Package dataplane is an implementation of the dataplane HAL API.
Package dataplane is an implementation of the dataplane HAL API.
forwarding
Package forwarding manages forwarding contexts and forwarding objects.
Package forwarding manages forwarding contexts and forwarding objects.
forwarding/fwdaction
Package fwdaction contains routines and types to manage forwarding actions.
Package fwdaction contains routines and types to manage forwarding actions.
forwarding/fwdaction/actions
Package actions implements various types of actions supported within Lucius.
Package actions implements various types of actions supported within Lucius.
forwarding/fwdaction/mock_fwdpacket
Package mock_fwdpacket is a generated GoMock package.
Package mock_fwdpacket is a generated GoMock package.
forwarding/fwdaction/mock_fwdport
Package mock_fwdport is a generated GoMock package.
Package mock_fwdport is a generated GoMock package.
forwarding/fwdaction/mock_fwdtable
Package mock_fwdtable is a generated GoMock package.
Package mock_fwdtable is a generated GoMock package.
forwarding/fwdport
Package fwdport contains routines and types to manage forwarding ports.
Package fwdport contains routines and types to manage forwarding ports.
forwarding/fwdport/mock_fwdpacket
Package mock_fwdpacket is a generated GoMock package.
Package mock_fwdpacket is a generated GoMock package.
forwarding/fwdport/ports
Package ports implements various types of ports supported within Lucius.
Package ports implements various types of ports supported within Lucius.
forwarding/fwdport/porttestutil
Package porttestutil contains routines used to create and manage ports for test cases.
Package porttestutil contains routines used to create and manage ports for test cases.
forwarding/fwdtable
Package fwdtable contains routines and types to manage forwarding tables.
Package fwdtable contains routines and types to manage forwarding tables.
forwarding/fwdtable/bridge
Package bridge implements an exact match table that operates on the packet's mac address.
Package bridge implements an exact match table that operates on the packet's mac address.
forwarding/fwdtable/exact
Package exact implements a Lucius table that performs packet matches using an exact match match and satisfies the interface fwdtable.Table.
Package exact implements a Lucius table that performs packet matches using an exact match match and satisfies the interface fwdtable.Table.
forwarding/fwdtable/flow
Package flow implements a Lucius table that performs packet matches using an flow matching and satisfies the interface fwdtable.Table.
Package flow implements a Lucius table that performs packet matches using an flow matching and satisfies the interface fwdtable.Table.
forwarding/fwdtable/mock_fwdpacket
Package mock_fwdpacket is a generated GoMock package.
Package mock_fwdpacket is a generated GoMock package.
forwarding/fwdtable/prefix
Package prefix implements a Lucius table that performs packet matches using the longest prefix match and satisfies the interface fwdtable.Table.
Package prefix implements a Lucius table that performs packet matches using the longest prefix match and satisfies the interface fwdtable.Table.
forwarding/fwdtable/tabletestutil
Package tabletestutil consists of routines used to test Lucius tables like prefix match, exact match and flow match tables.
Package tabletestutil consists of routines used to test Lucius tables like prefix match, exact match and flow match tables.
forwarding/fwdtable/tableutil
Package tableutil contains utilites used to implement tables in Lucius like prefix, flow and exact match.
Package tableutil contains utilites used to implement tables in Lucius like prefix, flow and exact match.
forwarding/infra/deadlock
Package deadlock is a set of simple utilities meant to detect deadlocks based on timeouts.
Package deadlock is a set of simple utilities meant to detect deadlocks based on timeouts.
forwarding/infra/fwdattribute
Package fwdattribute provides types and mechanisms used to manage attributes for forwarding objects.
Package fwdattribute provides types and mechanisms used to manage attributes for forwarding objects.
forwarding/infra/fwdcontext
Package fwdcontext contains routines for managing the context of the forwarding engine.
Package fwdcontext contains routines for managing the context of the forwarding engine.
forwarding/infra/fwdflowcounter
Package fwdflowcounter implements the functionality of Flow Counters.
Package fwdflowcounter implements the functionality of Flow Counters.
forwarding/infra/fwdobject
Package fwdobject contains routines and interfaces used to implement various forwarding objects.
Package fwdobject contains routines and interfaces used to implement various forwarding objects.
forwarding/infra/fwdpacket
Package fwdpacket contains routines and types for manipulating packets.
Package fwdpacket contains routines and types for manipulating packets.
forwarding/infra/fwdset
Package fwdset implements a set of members.
Package fwdset implements a set of members.
forwarding/protocol
Package protocol enables Lucius to uniformly query and mutate network packets containing various protocols.
Package protocol enables Lucius to uniformly query and mutate network packets containing various protocols.
forwarding/protocol/arp
Package arp implements the ARP header.
Package arp implements the ARP header.
forwarding/protocol/ethernet
Package ethernet implements the Ethernet header.
Package ethernet implements the Ethernet header.
forwarding/protocol/icmp
Package icmp implements the ICMP header support in Lucius.
Package icmp implements the ICMP header support in Lucius.
forwarding/protocol/ip
Package ip handles the IP L3 portion of the packet.
Package ip handles the IP L3 portion of the packet.
forwarding/protocol/metadata
Package metadata implements the metadata packet header.
Package metadata implements the metadata packet header.
forwarding/protocol/opaque
Package opaque implements the opaque packet header.
Package opaque implements the opaque packet header.
forwarding/protocol/packettestutil
Package packettestutil contains a set of routines used to test the processing of packet headers and fields.
Package packettestutil contains a set of routines used to test the processing of packet headers and fields.
forwarding/protocol/tcp
Package tcp implements the TCP header support in Lucius.
Package tcp implements the TCP header support in Lucius.
forwarding/protocol/udp
Package udp implements the UDP header support in Lucius.
Package udp implements the UDP header support in Lucius.
forwarding/util/frame
Package frame contains utilities to implement various network protocols and describe their relationship within Lucius.
Package frame contains utilities to implement various network protocols and describe their relationship within Lucius.
forwarding/util/hash/crc16
Package crc16 computes the 16 bit checksum over a series of bytes.
Package crc16 computes the 16 bit checksum over a series of bytes.
forwarding/util/hash/csum16
Package csum16 computes the 16 bit Internet checksum.
Package csum16 computes the 16 bit Internet checksum.
forwarding/util/hash/hash16
Package hash16 provides interfaces for functions computing 16 bit hashes.
Package hash16 provides interfaces for functions computing 16 bit hashes.
forwarding/util/queue
Package queue provides a queue to processes elements in FIFO order using a specified handler, while allowing non-blocking writes to the queue.
Package queue provides a queue to processes elements in FIFO order using a specified handler, while allowing non-blocking writes to the queue.
forwarding/util/stats
Package stats implements Stats that collects data.
Package stats implements Stats that collects data.
handlers
Package handlers contains gNMI task handlers.
Package handlers contains gNMI task handlers.
internal/engine
Package engine contains funcs for interacting with the forwarding engine.
Package engine contains funcs for interacting with the forwarding engine.
internal/kernel
Package kernel contains funcs that interact with the kernel (sycalls, netlink).
Package kernel contains funcs that interact with the kernel (sycalls, netlink).
internal/kernel/kerneltest
package kerneltest contains fake implemetation of structs in kernel package
package kerneltest contains fake implemetation of structs in kernel package
Package gnmi contains a reference on-device gNMI implementation.
Package gnmi contains a reference on-device gNMI implementation.
gnmiclient
Package gnmiclient contains a funcs to create gNMI for the local cache.
Package gnmiclient contains a funcs to create gNMI for the local cache.
oc
Package oc is a generated package which contains definitions of structs which represent a YANG schema.
Package oc is a generated package which contains definitions of structs which represent a YANG schema.
oc/acl
Package acl is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
Package acl is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
oc/bgpgue
Package bgpgue is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
Package bgpgue is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
oc/definedsets
Package definedsets is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
Package definedsets is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
oc/interfaces
Package interfaces is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
Package interfaces is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
oc/keychain
Package keychain is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
Package keychain is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
oc/lacp
Package lacp is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
Package lacp is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
oc/lldp
Package lldp is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
Package lldp is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
oc/networkinstance
Package networkinstance is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
Package networkinstance is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
oc/ocpath
Package ocpath is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
Package ocpath is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
oc/platform
Package platform is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
Package platform is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
oc/qos
Package qos is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
Package qos is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
oc/routingpolicy
Package routingpolicy is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
Package routingpolicy is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
oc/system
Package system is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
Package system is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
reconciler
Package reconciler contains a common interface for gNMI reconciler.
Package reconciler contains a common interface for gNMI reconciler.
acltrie
Package acltrie contains a trie for gNMI path with a corresponding policy.
Package acltrie contains a trie for gNMI path with a corresponding policy.
pathz
Package pathz is a gNSI pathz server.
Package pathz is a gNSI pathz server.
internal
binding
Package binding wraps knebind to allow running integration tests without the need to supply kne/ondatra flags for configuration files.
Package binding wraps knebind to allow running integration tests without the need to supply kne/ondatra flags for configuration files.
debug
Package debug contains flag for turning on or off debug messages.
Package debug contains flag for turning on or off debug messages.
packetutil
Package packetutil contains utilities for packets.
Package packetutil contains utilities for packets.
operator module
proto
Package sysrib implements a system-level RIB that is populated initially using an OpenConfig configuration.
Package sysrib implements a system-level RIB that is populated initially using an OpenConfig configuration.

Jump to

Keyboard shortcuts

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