gnmidiff

package
v0.29.5 Latest Latest
Warning

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

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

README

Usage

$ go install ./gnmidiff

$ gnmidiff setrequest cmd/demo/setrequest.textproto cmd/demo/setrequest2.textproto

SetRequestIntentDiff(-A, +B):
-------- deletes/replaces --------
+ /network-instances/network-instance[name=VrfBlue]: deleted or replaced only in B
-------- updates --------
m /system/config/hostname:
  - "violetsareblue"
  + "rosesarered"

$ gnmidiff set-to-notifs cmd/demo/setrequest.textproto cmd/demo/notifs.textproto

SetToNotifsDiff(-want/SetRequest, +got/Notifications):
- /lacp/interfaces/interface[name=Port-Channel9]/config/interval: "FAST"
- /lacp/interfaces/interface[name=Port-Channel9]/config/name: "Port-Channel9"
- /lacp/interfaces/interface[name=Port-Channel9]/name: "Port-Channel9"
- /network-instances/network-instance[name=VrfBlue]/config/name: "VrfBlue"
- /network-instances/network-instance[name=VrfBlue]/config/type: "openconfig-network-instance-types:L3VRF"
- /network-instances/network-instance[name=VrfBlue]/name: "VrfBlue"
m /system/config/hostname:
  - "violetsareblue"
  + "rosesarered"

$ gnmidiff set-to-notifs cmd/demo/setrequest.textproto cmd/demo/getresponse.textproto

SetToNotifsDiff(-want/SetRequest, +got/Notifications):
- /lacp/interfaces/interface[name=Port-Channel9]/config/interval: "FAST"
- /lacp/interfaces/interface[name=Port-Channel9]/config/name: "Port-Channel9"
- /lacp/interfaces/interface[name=Port-Channel9]/name: "Port-Channel9"
- /network-instances/network-instance[name=VrfBlue]/config/name: "VrfBlue"
- /network-instances/network-instance[name=VrfBlue]/config/type: "openconfig-network-instance-types:L3VRF"
- /network-instances/network-instance[name=VrfBlue]/name: "VrfBlue"
m /system/config/hostname:
  - "violetsareblue"
  + "rosesarered"

Documentation

Overview

gnmidiff contains gNMI utilities for diffing SetRequests and GetResponses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeleteDiff

type DeleteDiff struct {
	MissingDeletes map[string]struct{}
	ExtraDeletes   map[string]struct{}
	CommonDeletes  map[string]struct{}
}

DeleteDiff contains a set of difference fields representing delete paths.

The key of the maps is the string representation of a gpb.Path constructed by ygot.PathToString.

type Format

type Format struct {
	// Full indicates that common values are also output.
	Full bool
	// contains filtered or unexported fields
}

Format is the string format of any gNMI diff utility in this package.

type MismatchedUpdate

type MismatchedUpdate struct {
	// A is the update value in A.
	A interface{}
	// B is the update value in B.
	B interface{}
}

MismatchedUpdate represents two different update values for the same leaf node.

type SetRequestIntentDiff

type SetRequestIntentDiff StructuredDiff

SetRequestIntentDiff contains the intent difference between two SetRequests.

func DiffSetRequest

func DiffSetRequest(a *gpb.SetRequest, b *gpb.SetRequest, schema *ytypes.Schema) (SetRequestIntentDiff, error)

DiffSetRequest returns a unique and minimal intent diff of two SetRequests.

schema is intended to be provided via the function defined in generated ygot code (e.g. exampleoc.Schema). If schema is nil, then DiffSetRequest will make the following assumption: - Any JSON value in the input SetRequest MUST conform to the OpenConfig YANG style guidelines. See the following for checking compliance. * https://github.com/openconfig/oc-pyang * https://github.com/openconfig/public/blob/master/doc/openconfig_style_guide.md

Currently, support is only for SetRequests whose delete, replace and updates that don't have conflicts. If a conflict exists, then an error will be returned.

func (SetRequestIntentDiff) Format

func (diff SetRequestIntentDiff) Format(f Format) string

Format outputs the SetRequestIntentDiff in human-readable format.

NOTE: Do not depend on the output of this being stable.

type SetToNotifsDiff

type SetToNotifsDiff UpdateDiff

SetToNotifsDiff contains the difference from the SetRequest to the given Notifications.

func DiffSetRequestToNotifications

func DiffSetRequestToNotifications(setreq *gpb.SetRequest, notifs []*gpb.Notification, schema *ytypes.Schema) (SetToNotifsDiff, error)

DiffSetRequestToNotifications returns a diff between a SetRequest and a slice of Notifications representing the state of the target after applying the SetRequest.

schema is intended to be provided via the function defined in generated ygot code (e.g. exampleoc.Schema). If schema is not supplied, then any input JSON values MUST conform to the OpenConfig YANG style guidelines. See the following for checking compliance. * https://github.com/openconfig/oc-pyang * https://github.com/openconfig/public/blob/master/doc/openconfig_style_guide.md

func (SetToNotifsDiff) Format

func (diff SetToNotifsDiff) Format(f Format) string

Format outputs the SetToNotifsDiff in human-readable format.

NOTE: Do not depend on the output of this being stable.

type StructuredDiff

type StructuredDiff struct {
	DeleteDiff
	UpdateDiff
}

StructuredDiff contains a set of difference fields that can be used by SetRequests/Notifications.

- The key of the maps is the string representation of a gpb.Path constructed by ygot.PathToString. - The value of the update fields is the JSON_IETF representation of the value. This is to facilitate comparing JSON_IETF-represented values whose real data type is obscured without knowledge of the YANG schema.

func (StructuredDiff) Format

func (diff StructuredDiff) Format(f Format) string

Format outputs the SetRequestIntentDiff in human-readable format.

NOTE: Do not depend on the output of this being stable.

type UpdateDiff

type UpdateDiff struct {
	// MissingUpdates (-) are updates specified in the first argument but
	// missing in the second argument.
	MissingUpdates map[string]interface{}
	// ExtraUpdates (+) are updates not specified in the first argument but
	// present in the second argument.
	ExtraUpdates      map[string]interface{}
	CommonUpdates     map[string]interface{}
	MismatchedUpdates map[string]MismatchedUpdate
}

UpdateDiff contains a set of update fields representing update path/values.

- The key of the maps is the string representation of a gpb.Path constructed by ygot.PathToString. - The value of the update fields is the JSON_IETF representation of the value. This is to facilitate comparing JSON_IETF-represented values whose real data type is obscured without knowledge of the YANG schema.

Directories

Path Synopsis
Package cmd contains a CLI utility to access gnmidiff functionality.
Package cmd contains a CLI utility to access gnmidiff functionality.
gnmiparse contains utilities for parsing the textproto of gNMI messages.
gnmiparse contains utilities for parsing the textproto of gNMI messages.

Jump to

Keyboard shortcuts

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