Git Product home page Git Product logo

entity-naming's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

entity-naming's Issues

Basic usage example

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

Implementing Line Card Port function

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 interface
  • xe—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
}

Break down of Device Chassis and LineCard

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.