resource

package
v0.1.233 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2021 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPathElem

func AddPathElem(p *gnmi.Path, e *container.Entry) *gnmi.Path

func DeepCopyConfigPath

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

Types

type HeInfo

type HeInfo struct {
	Name string `json:"name,omitempty"`
	Key  string `json:"key,omitempty"`
	Type string `json:"type,omitempty"`
}

type HierResourceElements added in v0.1.177

type HierResourceElements struct {
	Elems map[string]interface{}
}

func NewHierResourceElements added in v0.1.177

func NewHierResourceElements() *HierResourceElements

func (*HierResourceElements) AddHierResourceElement added in v0.1.177

func (h *HierResourceElements) AddHierResourceElement(path string)

builds a hierarchical map[string]map[string]nil element

func (*HierResourceElements) GetHierResourceElements added in v0.1.177

func (h *HierResourceElements) GetHierResourceElements() map[string]interface{}

builds a hierarchical map[string]map[string]nil element

type Option

type Option func(g *Resource)

Option can be used to manipulate Options.

func WithDependsOn

func WithDependsOn(d *Resource) Option

func WithDependsOnPath added in v0.1.152

func WithDependsOnPath(p *gnmi.Path) Option

func WithExclude

func WithExclude(p string) Option

func WithModule added in v0.1.129

func WithModule(m string) Option

func WithSubResources added in v0.1.184

func WithSubResources(s []*gnmi.Path) Option

func WithXPath

func WithXPath(p string) Option

type Resource

type Resource struct {
	Module string // Yang Module name of the resource

	Path                 *gnmi.Path                     // relative path from the resource; the absolute path is assembled using the resurce hierarchy with dependsOn
	ActualPath           *gnmi.Path                     // ActualPath is a relative path from the resource with the actual key information; the absolute path is assembled using the resurce hierarchy with dependsOn
	DependsOn            *Resource                      // resource dependency
	DependsOnPath        *gnmi.Path                     // the full path the resource depends upon
	Excludes             []*gnmi.Path                   // relative from the the resource
	FileName             string                         // the filename the resource is using to render out the config
	ResFile              *os.File                       // the file reference for writing the resource file
	RootContainerEntry   *container.Entry               // this is the root element which is used to reference the hierarchical resource information
	Container            *container.Container           // root container of the resource
	LastContainerPtr     *container.Container           // pointer to the last container we process
	ContainerList        []*container.Container         // List of all containers within the resource
	ContainerLevel       int                            // the current container Level when processing the yang entries
	ContainerLevelKeys   map[int][]*container.Container // the current container Level key list
	LocalLeafRefs        []*parser.LeafRefGnmi
	ExternalLeafRefs     []*parser.LeafRefGnmi
	HierResourceElements *HierResourceElements // this defines the hierarchical elements the resource is dependent upon (map[string]interface -> map[string]map[string]map[string]interface{})
	SubResources         []*gnmi.Path          // for the fine grain reosurce allocation we sometimes see we need subresources: e.g. ipam has rir and instance within the parent
	// contains filtered or unexported fields
}

func NewResource

func NewResource(opts ...Option) *Resource

func (*Resource) AddExternalLeafRef

func (r *Resource) AddExternalLeafRef(ll, rl *gnmi.Path)

func (*Resource) AddLocalLeafRef

func (r *Resource) AddLocalLeafRef(ll, rl *gnmi.Path)

func (*Resource) AssignFileName

func (r *Resource) AssignFileName(prefix, suffix string)

func (*Resource) CloseFile

func (r *Resource) CloseFile() error

func (*Resource) CreateFile

func (r *Resource) CreateFile(dir, subdir1, subdir2 string) (err error)

func (*Resource) GetAbsoluteGnmiActualResourcePath

func (r *Resource) GetAbsoluteGnmiActualResourcePath() *gnmi.Path

root resource have an additional entry in the path which is inconsistent with hierarchical resources to provide consistency we introduced this method to provide a consistent result for paths used mainly for leafrefs for now

func (*Resource) GetAbsoluteGnmiPath

func (r *Resource) GetAbsoluteGnmiPath() *gnmi.Path

func (*Resource) GetAbsoluteLevel

func (r *Resource) GetAbsoluteLevel() int

func (*Resource) GetAbsoluteName

func (r *Resource) GetAbsoluteName() string

func (*Resource) GetAbsoluteXPath

func (r *Resource) GetAbsoluteXPath() *string

func (*Resource) GetAbsoluteXPathWithoutKey

func (r *Resource) GetAbsoluteXPathWithoutKey() *string

func (*Resource) GetActualGnmiFullPathWithKeys added in v0.1.169

func (r *Resource) GetActualGnmiFullPathWithKeys() *gnmi.Path

func (*Resource) GetActualSubResources added in v0.1.185

func (r *Resource) GetActualSubResources() []*gnmi.Path

GetActualSubResources contaians the full path of all subresources the first pathElement is a Dummy but is used in the structs so we retain it inn the response

func (*Resource) GetDependsOn added in v0.1.151

func (r *Resource) GetDependsOn() *Resource

func (*Resource) GetDependsOnPath added in v0.1.153

func (r *Resource) GetDependsOnPath() *gnmi.Path

func (*Resource) GetExcludeRelativeXPath

func (r *Resource) GetExcludeRelativeXPath() []string

func (*Resource) GetExternalLeafRef

func (r *Resource) GetExternalLeafRef() []*parser.LeafRefGnmi

func (*Resource) GetHierResourceElement added in v0.1.180

func (r *Resource) GetHierResourceElement() *HierResourceElements

GetHierResourceElement return the hierarchical resource element

func (*Resource) GetHierResourceElements added in v0.1.177

func (r *Resource) GetHierResourceElements() *HierResourceElements

func (*Resource) GetHierarchicalElements

func (r *Resource) GetHierarchicalElements() []*HeInfo

func (*Resource) GetInternalHierarchicalPaths

func (r *Resource) GetInternalHierarchicalPaths() []*gnmi.Path

func (*Resource) GetLocalLeafRef

func (r *Resource) GetLocalLeafRef() []*parser.LeafRefGnmi

func (*Resource) GetModule added in v0.1.129

func (r *Resource) GetModule() string

func (*Resource) GetPath

func (r *Resource) GetPath() *gnmi.Path

GetPath returns the relative Path of the resource For the root resources we need to strip the first entry of the path since srl uses some prefix entry

func (*Resource) GetRelativeGnmiActualResourcePath

func (r *Resource) GetRelativeGnmiActualResourcePath() *gnmi.Path

root resource have a additional entry in the path which is inconsistent with hierarchical resources to provide consistencyw e introduced this method to provide a consistent result for paths used mainly for leafrefs for now

func (*Resource) GetRelativeGnmiPath

func (r *Resource) GetRelativeGnmiPath() *gnmi.Path

func (*Resource) GetRelativeXPath

func (r *Resource) GetRelativeXPath() *string

func (*Resource) GetResourceNameWithPrefix

func (r *Resource) GetResourceNameWithPrefix(prefix string) string

func (*Resource) GetResourcePath added in v0.1.89

func (r *Resource) GetResourcePath() *gnmi.Path

func (*Resource) GetRootContainerEntry

func (r *Resource) GetRootContainerEntry() *container.Entry

func (*Resource) GetSubResources added in v0.1.184

func (r *Resource) GetSubResources() []*gnmi.Path

func (*Resource) ResourceLastElement

func (r *Resource) ResourceLastElement() string

func (*Resource) SetRootContainerEntry

func (r *Resource) SetRootContainerEntry(e *container.Entry)

Jump to

Keyboard shortcuts

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