-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementing Line Card Port function #33
Comments
Before I submit a PR for Juniper devices, how would something like this look to you:
const (
GE = "ge"
ET = "et"
TE = "te"
XE = "xe"
)
var speedStrings = map[string]string{
// Gigabit Ethernet MIC with SFP.
"MIC-3D-20GE-SFP":"GE",
// Gigabit Ethernet MIC with SFP (E).
"MIC-3D-20GE-SFP-E":"GE",
// 10-Gigabit Ethernet MICs with XFP.
"MIC-3D-2XGE-XFP":"XE",
"MIC-3D-4XGE-XFP":"XE",
// 10-Gigabit Ethernet MIC with SFP+.
"MIC3-3D-10XGE-SFPP":"XE",
// 40-Gigabit Ethernet MIC with QSFP+.
"MIC3-3D-2X40GE-QSFPP":"ET",
// 16-Port Gigabit Ethernet XPIM (with PoE)
"SRX-GP-16GE-POE":"GE",
// 100-Gigabit Ethernet MIC with CFP
"MIC3-3D-1X100GE-CFP": "ET",
}
// Port is an implementation of namer.Port.
func (n *Namer) Port(pp *namer.PortParams) (string, error) {
if !pp.Channelizable {
return "", fmt.Errorf("Juniper does not support unchannelizable ports")
}
speed := "et"
ifsymb, ok := speedStrings[n.HardwareModel]
if ok {
speed = ifsymb
}
var nameBuilder strings.Builder
nameBuilder.WriteString(speed + "-")
if pp.SlotIndex == nil {
nameBuilder.WriteString("0/")
} else {
nameBuilder.WriteString(fmt.Sprintf("%d/", *pp.SlotIndex))
}
nameBuilder.WriteString(fmt.Sprintf("%d", pp.PICIndex))
nameBuilder.WriteString(fmt.Sprintf("/%d", pp.PortIndex))
if pp.ChannelIndex != nil {
nameBuilder.WriteString(fmt.Sprintf(":%d", *pp.ChannelIndex))
}
return nameBuilder.String(), nil
} Thanks |
Hi Nicolas, That looks like a good solution to me. As a small nit, that I realize is not coming from you - we can also put together the namebuilder lines after the if statement:
|
This is a bit of a tangent,but I think we should define what Further, the PORT component probably does not have a useful model-name. Rather one could use the component tree to resolve the parent of the port, recursing up to the first component of type LINECARD or CHASSIS to determine the |
Thanks! Yeah, I didn't modify the name-building pattern to keep the example as close as the current implementation. |
This is a great point. I see the model also has an // / openconfig-platform/components/component
type Component struct {
Chassis *Component_Chassis `path:"chassis" module:"openconfig-platform"`
InstallPosition *string `path:"state/install-position" module:"openconfig-platform/openconfig-platform"`
Linecard *Component_Linecard `path:"linecard" module:"openconfig-platform-linecard"`
ModelName *string `path:"state/model-name" module:"openconfig-platform/openconfig-platform"`
Port *Component_Port `path:"port" module:"openconfig-platform"`
}
type Component_Chassis struct {
Utilization *Component_Chassis_Utilization `path:"utilization" module:"openconfig-platform"`
}
type Component_Linecard struct {
PowerAdminState E_PlatformTypes_ComponentPowerType `path:"config/power-admin-state" module:"openconfig-platform-linecard/openconfig-platform-linecard"`
SlotId *string `path:"state/slot-id" module:"openconfig-platform-linecard/openconfig-platform-linecard"`
Utilization *Component_Linecard_Utilization `path:"utilization" module:"openconfig-platform-linecard"`
}
type Component_Port struct {
} |
Yes, |
Hi,
How do you envision implementing other Line Cards for a given vendor? Do you expand the Vendor
Port
function matching onHardwareModel
?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
beforenameBuilder.WriteString("et-")
and also changenameBuilder.WriteString("/0")
tonameBuilder.WriteString(fmt.Sprintf("%d", pp.PICIndex))
. Does that sound correct to you?The text was updated successfully, but these errors were encountered: