knebind

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2023 License: Apache-2.0 Imports: 39 Imported by: 1

README

KNE Binding

The KNE Binding is an implementation of the Ondatra binding interface that runs on a network topology created with openconfig/kne.

Config File

The KNE Binding requires a YAML config file that lets the binding know how to connect to your KNE topology. The YAML must be specified in a -config flag passed to the Ondatra test. The file supports the following keys:

Key Required? Description
username no default username to log into the KNE nodes
password no default password to log into the KNE nodes
credentials no map of credentials to use for specific nodes / vendors
topology yes path to a KNE topology text proto
cli no path to the kne binary
kubecfg no path to your kubeconfig file
skip_reset no if true, skip initial device reset that happens during reservation

If cli and kubecfg are not specified, they will be inferred from the PATH environment.

A basic example YAML config file:

username: tester
password: hunter2
topology: /home/tester/topo.textproto
Device Credentials

An example YAML config file with optional extra credential fields:

username: tester
password: hunter2
credentials:
  node:
    r1:
      username: user
      password: pass
    r2:
      username: root
      password: root123
  vendor:
    ARISTA:
      username: admin
      password: admin
topology: /home/tester/topo.textproto

The per-node credentials are used over the per-vendor credentials. The default username/password are used if there are no matches. A precedence order is defined below:

  1. credential provided for a specific node by name
  2. credential provided for a vendor of the node
  3. credential from the default username and password fields
  4. no credentials

Running the Integration Test

This repo includes an example integration test that uses the KNE binding, a testbed file for that test, and a KNE topology file that is matched by the testbed. To execute the test, you must:

  1. create a local KNE topology with at least two linked nodes, as the testbed requires
  2. create a config file for your topology, as specified above
  3. run the test passing both the testbed and config file flags:
go test -testbed=testbed.textproto -config=path/to/config.yaml

A YAML config file that works with that topology is:

username: admin
password: admin
topology: /[YOUR GIT CLONE PATH]/ondatra/knebind/integration/topology.textproto

Documentation

Overview

Package knebind provides an Ondatra binding for KNE devices.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bind

type Bind struct {
	binding.Binding
	// contains filtered or unexported fields
}

Bind implements the ondatra Binding interface for KNE

func New

func New(cfg *Config) (*Bind, error)

New returns a new KNE bind instance.

func (*Bind) Release

func (b *Bind) Release(context.Context) error

Release is a no-op because there's need to reserve local VMs.

func (*Bind) Reserve

func (b *Bind) Reserve(ctx context.Context, tb *opb.Testbed, runTime time.Duration, waitTime time.Duration, partial map[string]string) (*binding.Reservation, error)

Reserve implements the binding Reserve method by finding nodes and links in the topology specified in the config file that match the requested testbed.

type Config

type Config struct {
	// TODO(team): Deprecate username and password fields. Add option inside credentials field.
	Username, Password string
	Credentials        *Credentials `yaml:"credentials"`
	TopoPath           string       `yaml:"topology"`
	CLIPath            string       `yaml:"cli"`
	KubecfgPath        string       `yaml:"kubecfg"`
	SkipReset          bool         `yaml:"skip_reset"`
}

Config contains parameters to configure the KNE binding. They are all exported so they can be unmarhalled from YAML.

func ParseConfigFile

func ParseConfigFile(configFile string) (*Config, error)

ParseConfigFile parses a yaml file containing a serialized Config.

func (*Config) String

func (c *Config) String() string

type Credentials

type Credentials struct {
	Node   map[string]*UserPass     `yaml:"node"`
	Vendor map[tpb.Vendor]*UserPass `yaml:"vendor"`
}

Credentials contains credential maps for nodes in the KNE topology.

func (*Credentials) UnmarshalYAML

func (c *Credentials) UnmarshalYAML(unmarshal func(any) error) error

UnmarshalYAML allows the Credentials type to be correctly unmarshaled from yaml.

type UserPass

type UserPass struct {
	Username string `yaml:"username"`
	Password string `yaml:"password"`
}

UserPass contains a username and password combination.

Directories

Path Synopsis
Package init installs the Ondatra binding for testing with kne clusters.
Package init installs the Ondatra binding for testing with kne clusters.
Package solver creates solutions from devices and topologies.
Package solver creates solutions from devices and topologies.

Jump to

Keyboard shortcuts

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