yparser

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2022 License: Apache-2.0 Imports: 16 Imported by: 5

Documentation

Index

Constants

View Source
const (
	CacheTypeState  = "STATE"
	CacheTypeConfig = "CONFIG"
	CacheTypeTarget = "TARGET"
)

Variables

This section is empty.

Functions

func AddDataToList added in v0.1.226

func AddDataToList(x interface{}) (interface{}, error)

func CleanConfig added in v0.1.439

func CleanConfig(x1 map[string]interface{}) map[string]interface{}

func CleanConfig2String added in v0.1.439

func CleanConfig2String(cfg map[string]interface{}) (map[string]interface{}, *string, error)

CleanConfig2String returns a clean config and a string clean means removing the prefixes in the json elements

func CompareGnmiPathsWithResourceKeys added in v0.1.517

func CompareGnmiPathsWithResourceKeys(rootPath *gnmi.Path, origResourceKeys map[string]string) (bool, []*gnmi.Path, map[string]string)

CompareConfigPathsWithResourceKeys returns changed true when resourceKeys were provided and if they are different. In this case the deletePath is also valid, otherwise when changd is false the delete path is not reliable

func CreateContainerEntry added in v0.1.397

func CreateContainerEntry(e *yang.Entry, next, prev *container.Container, containerKey string) *container.Entry

CreateContainerEntry used by ygen

func CreatePathElem added in v0.1.397

func CreatePathElem(e *yang.Entry) *gnmi.PathElem

CreatePathElem returns a config path element from a yang Entry used by ygen

func DeepCopyGnmiPath

func DeepCopyGnmiPath(in *gnmi.Path) *gnmi.Path

func FindResourceDelta added in v0.1.227

func FindResourceDelta(updatesx1, updatesx2 []*gnmi.Update) ([]*gnmi.Path, []*gnmi.Update, error)

func GetDataType added in v0.1.234

func GetDataType(t gnmi.GetRequest_DataType) string

func GetGranularUpdatesFromJSON added in v0.1.224

func GetGranularUpdatesFromJSON(p *gnmi.Path, d interface{}, rs *yentry.Entry) ([]*gnmi.Update, error)

GetGranularUpdatesFromJSON provides an update per leaf level

func GetHierIDsFromPath added in v0.1.225

func GetHierIDsFromPath(p *gnmi.Path) []string

GetHierIDsFromPath from path gets the hierarchical ids from the gnmi path

func GetRemotePathsFromResolvedLeafRef added in v0.1.276

func GetRemotePathsFromResolvedLeafRef(resolvedLeafRef *leafref.ResolvedLeafRef) []*gnmi.Path

func GetTypeKind

func GetTypeKind(e *yang.Entry) string

GetTypeKind returns a string of the kind of the yang entry

func GetTypeName

func GetTypeName(e *yang.Entry) string

GetypeName return a string of the type of the yang entry

func GetUpdatesFromJSON added in v0.1.224

func GetUpdatesFromJSON(p *gnmi.Path, d interface{}, rs *yentry.Entry) ([]*gnmi.Update, error)

GetUpdatesFromJSON provides an update per container, list and leaflist level

func GetValue added in v0.1.227

func GetValue(updValue *gnmi.TypedValue) (interface{}, error)

GetValue return the data of the gnmi typed value

func GnmiPath2XPath

func GnmiPath2XPath(path *gnmi.Path, keys bool) string

GnmiPath2XPath converts a gnmi path with or without keys to a string pointer

func GnmiPathToName added in v0.1.398

func GnmiPathToName(path *gnmi.Path) string

GnmiPathToName converts a gnmi path to a name where each element of the path is seperated by a "-"

func GnmiPathToSubResourceName added in v0.1.286

func GnmiPathToSubResourceName(path *gnmi.Path) string

GnmiPathToSubResourceName special case since we have to remove the - from the first elemen used in nddbuilder

func ParseStringPath added in v0.2.7

func ParseStringPath(stringPath string) ([]interface{}, error)

ParseStringPath parses a string path and produces a []interface{} of parsed path elements. Path elements in a string path are separated by '/'. Each path element can either be a schema node name or a List path element. Schema node names must be valid YANG identifiers. A List path element is encoded using the following pattern: list-name[key1=value1]...[keyN=valueN]. Each List path element generates two parsed path elements: List name and a map[string]string containing List key-value pairs with value(s) in string representation. A '/' within a List key value pair string, i.e., between a pair of '[' and ']', does not serve as a path separator, and is allowed to be part of a List key leaf value. For example, given a string path:

"/a/list-name[k=v/v]/c",

this API returns:

[]interface{}{"a", "list-name", map[string]string{"k": "v/v"}, "c"}.

String path parsing consists of two passes. In the first pass, the input string is split into []string using valid separator '/'. An incomplete List key value string, i.e, a '[' which starts a List key value string without a closing ']', in input string generates an error. In the above example, this pass produces:

[]string{"a", "list-name[k=v/v]", "c"}.

In the second pass, each element in split []string is parsed checking syntax and pattern correctness. Errors are generated for invalid YANG identifiers, malformed List key-value string, etc.. In the above example, the second pass produces:

[]interface{}{"a", "list-name", map[string]string{"k": "v/v"}, "c"}.

func ProcessLeafRef added in v0.1.275

func ProcessLeafRef(e *yang.Entry, resfullPath string, activeResPath *gnmi.Path) (*gnmi.Path, *gnmi.Path, bool)

ProcessLeafRef processes the leafref and returns if this is a leafref and if so the leafrefs local and remote path if the leafRef is local or external to the resource

func RemoveFirstEntryFromXpath

func RemoveFirstEntryFromXpath(s string) string

RemoveFirstEntryFromXpath removes the first entry of the xpath, so it trims the first element of the /

func RemoveHierIDsFomData added in v0.1.225

func RemoveHierIDsFomData(hids []string, x interface{}) interface{}

RemoveHierIDs removes the hierarchical IDs from the data

func ToGNMIPath added in v0.2.7

func ToGNMIPath(xpath string) (*gnmi.Path, error)

ToGNMIPath parses an xpath string into a gnmi Path struct defined in gnmi proto. Path convention can be found in https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-path-conventions.md

For example, xpath /interfaces/interface[name=Ethernet1/2/3]/state/counters will be parsed to:

elem: <name: "interfaces" >
elem: <
    name: "interface"
    key: <
        key: "name"
        value: "Ethernet1/2/3"
    >
>
elem: <name: "state" >
elem: <name: "counters" >

func ValidateLeafRef added in v0.1.277

func ValidateLeafRef(rootPath *gnmi.Path, x1, x2 interface{}, definedLeafRefs []*leafref.LeafRef, rs *yentry.Entry) (bool, []*leafref.ResolvedLeafRef, error)

func ValidateParentDependency added in v0.1.275

func ValidateParentDependency(x1 interface{}, parentDependencies []*leafref.LeafRef, rs *yentry.Entry) (bool, []*leafref.ResolvedLeafRef, error)

ValidateParentDependency validates the parent resource dependency based on the result this function returns the result + information on the validation we use a get here since we resolved the values of the keys alreay

func Xpath2GnmiPath

func Xpath2GnmiPath(xpath string, offset int) (path *gnmi.Path)

Xpath2GnmiPath converts a xpath string to a gnmi path

Types

type Operation added in v0.1.227

type Operation struct {
	Type  OperationType
	Path  string
	Value interface{}
}

func CompareJSONData added in v0.1.227

func CompareJSONData(t, s []byte) ([]Operation, error)

CompareJSONData compares the target with the source and provides operation guides

type OperationType added in v0.1.227

type OperationType string

A OperationType represents an operatio on a JSON resource

const (
	// delete
	OperationTypeDelete OperationType = "Delete"
	// replace
	OperationTypeUpdate OperationType = "Update"
	// create
	OperationTypeCreate OperationType = "Create"
)

Condition Kinds.

Jump to

Keyboard shortcuts

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