portgraph

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Overview

Package portgraph searches for a graph that satisfies a set of constraints.

Index

Constants

View Source
const (
	// HWAttr is the name of the node constraint on the hardware model attribute.
	HWAttr = "hardware_model"
	// NameAttr is the name of the node constraint on the name attribute.
	NameAttr = "name"
	// RoleAttr is the name of the node constraint on the role attribute.
	RoleAttr = "role"
	// SWAttr is the name of the node constraint on the software version attribute.
	SWAttr = "software_version"
	// VendorAttr is the name of the node constraint on the vendor attribute.
	VendorAttr = "vendor"

	// SpeedAttr is the name of the port constraint on the speed attribute.
	SpeedAttr = "speed"
	// CardAttr is the name of the port constraint on the card model attribute.
	CardAttr = "card_model"
	// PMDAttr is the name of the port constraint on the pmd attribute.
	PMDAttr = "pmd"
	// GroupAttr is the name of the port constraint on the group attribute.
	GroupAttr = "group"

	// RoleDUT is the name of the value of the role attribute for DUTs.
	RoleDUT = "DUT"
	// RoleATE is the name of the value of the role attribute for ATEs.
	RoleATE = "ATE"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AbstractEdge

type AbstractEdge struct {
	Src, Dst *AbstractPort
}

AbstractEdge represents a link from an source AbstractPort to a destination AbstractPort.

func (*AbstractEdge) String

func (e *AbstractEdge) String() string

type AbstractGraph

type AbstractGraph struct {
	Desc  string // Description for the AbstractGraph for logging.
	Nodes []*AbstractNode
	Edges []*AbstractEdge
}

AbstractGraph is a representation of abstract nodes, ports, and edges.

func TestbedToAbstractGraph added in v0.5.3

func TestbedToAbstractGraph(tb *opb.Testbed, partial map[string]string) (*AbstractGraph, map[*AbstractNode]*opb.Device, map[*AbstractPort]*opb.Port, error)

TestbedToAbstractGraph translates an Ondatra testbed to an AbstractGraph for solving.

func (*AbstractGraph) String added in v0.1.5

func (g *AbstractGraph) String() string

type AbstractNode

type AbstractNode struct {
	Desc        string                    // Description for the AbstractNode for logging.
	Ports       []*AbstractPort           // A list AbstractPorts that may be connected to another AbstractPort.
	Constraints map[string]NodeConstraint // A map of key value constraints of the AbstractNode.
}

AbstractNode represent a vertex on an AbstractGraph. The AbstractNode has AbstractPorts and AbstractEdges that originate and terminate at AbstractPorts.

type AbstractPort

type AbstractPort struct {
	Desc        string                    // Description for the AbstractPort for logging.
	Constraints map[string]PortConstraint // A map of key value constraints of the AbstractPort.
}

AbstractPort is a is point on an AbstractNode where an AbstractEdge may be attached.

type Assignment

type Assignment struct {
	Node2Node map[*AbstractNode]*ConcreteNode
	Port2Port map[*AbstractPort]*ConcretePort
}

Assignment contains the AbstractNode -> ConcreteNode and AbstractPort -> ConcretePort mappings.

func Solve

func Solve(ctx context.Context, abstractGraph *AbstractGraph, superGraph *ConcreteGraph) (*Assignment, error)

Solve returns an assignment from superGraph that satisfies abstractGraph. Solve accepts a context to handle termination if the solve takes too long.

type ConcreteEdge

type ConcreteEdge struct {
	Src, Dst *ConcretePort
}

ConcreteEdge represents a link from an source ConcretePort to a destination ConcretePort.

type ConcreteGraph

type ConcreteGraph struct {
	Desc  string // Description for the AbstractGraph for logging.
	Nodes []*ConcreteNode
	Edges []*ConcreteEdge
}

ConcreteGraph is a representation of concrete nodes, ports, and edges.

func (*ConcreteGraph) String added in v0.1.5

func (g *ConcreteGraph) String() string

type ConcreteNode

type ConcreteNode struct {
	Desc  string            // Description for the ConcreteNode for logging.
	Ports []*ConcretePort   // A list ConcretePorts that may be connected to another ConcretePort.
	Attrs map[string]string // A map of key value attributes of the ConctreteNode.
}

ConcreteNode represent a vertex on a ConcreteGraph. The ConcreteNode has ConcretePorts and ConcreteEdges that originate and terminate at ConcretePorts.

type ConcretePort

type ConcretePort struct {
	Desc  string            // Description for the ConcretePort for logging.
	Attrs map[string]string // A map of key value attributes of the ConcretePort.
}

ConcretePort is a is point on a ConcreteNode where a ConcreteEdge may be attached.

type LeafConstraint

type LeafConstraint interface {
	// contains filtered or unexported methods
}

LeafConstraint is a constraint checker that checks the input matches based on some matching criteria.

func Equal

func Equal(s string) LeafConstraint

Equal returns a constraint that an attribute is equal to the specified string.

func NotEqual

func NotEqual(s string) LeafConstraint

NotEqual returns a constraint that an attribute is not equal to the specified string.

func NotRegex

func NotRegex(re *regexp.Regexp) LeafConstraint

NotRegex returns a constraint that an attribute does not match the specified regex.

func Regex

func Regex(re *regexp.Regexp) LeafConstraint

Regex returns a constraint that an attribute matches the specified regex.

type LeafNodeConstraint

type LeafNodeConstraint interface {
	NodeConstraint
	// contains filtered or unexported methods
}

LeafNodeConstraint is a leaf constraint on a Node.

func NotSameAsNode

func NotSameAsNode(n *AbstractNode) LeafNodeConstraint

NotSameAsNode returns a constraint that an attribute has a different value from the specified Node.

func SameAsNode

func SameAsNode(n *AbstractNode) LeafNodeConstraint

SameAsNode returns a constraint that an attribute has the same value as the specified Node.

type LeafPortConstraint

type LeafPortConstraint interface {
	PortConstraint
	// contains filtered or unexported methods
}

LeafPortConstraint is a leaf constraint on a Port.

func NotSameAsPort

func NotSameAsPort(p *AbstractPort) LeafPortConstraint

NotSameAsPort returns a constraint that an attribute has a different value from the specified Port.

func SameAsPort

func SameAsPort(p *AbstractPort) LeafPortConstraint

SameAsPort returns a constraint that an attribute has the same value as the specified Port.

type NodeConstraint

type NodeConstraint interface {
	// contains filtered or unexported methods
}

NodeConstraint is a constraint on a Node.

func AndNode

func AndNode(nlcs ...LeafNodeConstraint) NodeConstraint

AndNode returns a constraint that contains other node constraints. An and constraint is a leaf constraint that cannot contain other leaves.

type PortConstraint

type PortConstraint interface {
	// contains filtered or unexported methods
}

PortConstraint is a constraint on a Port.

func AndPort

func AndPort(plcs ...LeafPortConstraint) PortConstraint

AndPort returns a constraint that contains other port constraints. An and constraint is a leaf constraint that cannot contain other leaves.

Jump to

Keyboard shortcuts

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