openconfig / entity-naming Goto Github PK
View Code? Open in Web Editor NEWLibraries for mapping canonical names of OpenConfig entities to platform specific implementations
License: Apache License 2.0
Libraries for mapping canonical names of OpenConfig entities to platform specific implementations
License: Apache License 2.0
Hi, first of all, really cool and useful project!
Second, in the example you reference naming
. What's that?
dev := &entname.DeviceParams{
Vendor: naming.JUNIPER,
HardwareModel: "PTX10008",
}
Here is a simple example I put together. Is this how you expect users to interact with it?
package main
import (
"fmt"
"github.com/openconfig/entity-naming/entname"
)
func main() {
dp := &entname.DeviceParams{
Vendor: entname.VendorJuniper,
HardwareModel: "PTX10008",
}
aggName, err := entname.AggregateInterface(dp, 0)
if err != nil {
panic(err)
}
fmt.Println(aggName)
LoName, err := entname.LoopbackInterface(dp, 0)
if err != nil {
panic(err)
}
fmt.Println(LoName)
pp := &entname.PortParams{
SlotIndex: 1,
PICIndex: 2,
PortIndex: 3,
// Unchannelized, Channelized, Unchannelizable
ChannelState: 0,
// IfEthernet_ETHERNET_SPEED_SPEED_100GB E_IfEthernet_ETHERNET_SPEED = 1
Speed: 1,
}
PoName, err := entname.Port(dp, pp)
if err != nil {
panic(err)
}
fmt.Println(PoName)
}
Thanks
Hi,
How do you envision implementing other Line Cards for a given vendor? Do you expand the Vendor Port
function matching on HardwareModel
?
Let's say I want to add support for other Juniper interfaces:
et
—Ethernet interfaces (10-, 25-, 40-, 50-, 100-, 200-, and 400-Gigabit Ethernet interface).ge
—Gigabit Ethernet interfacexe
—10-Gigabit Ethernet interface. Some older 10-Gigabit Ethernet interfaces use the ge media type (rather than xe) to identify the physical part of the network device (XENPAK 10-Gigabit Ethernet interface PIC, which is supported only on M series routers).Then, I'd have to check HardwareModel
before nameBuilder.WriteString("et-")
and also change nameBuilder.WriteString("/0")
to nameBuilder.WriteString(fmt.Sprintf("%d", pp.PICIndex))
. Does that sound correct to you?
unc (n *Namer) Port(pp *namer.PortParams) (string, error) {
if !pp.Channelizable {
return "", fmt.Errorf("Juniper does not support unchannelizable ports")
}
var nameBuilder strings.Builder
nameBuilder.WriteString("et-")
if pp.SlotIndex == nil {
nameBuilder.WriteString("0/")
nameBuilder.WriteString(fmt.Sprintf("%d", pp.PICIndex))
} else {
nameBuilder.WriteString(fmt.Sprintf("%d", *pp.SlotIndex))
nameBuilder.WriteString("/0")
}
nameBuilder.WriteString(fmt.Sprintf("/%d", pp.PortIndex))
if pp.ChannelIndex != nil {
nameBuilder.WriteString(fmt.Sprintf(":%d", *pp.ChannelIndex))
}
return nameBuilder.String(), nil
}
Hi,
In the usage example you use a device chassis (PTX10008
) as the HardwareModel
. If you used a different chassis (MX960
for example), the port name might depend on the line card per chassis slot. I'm wondering if you considered expanding HardwareModel
to include both, the chassis and line card to accurately identify the port naming convention.
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.