openconfig / entity-naming

Libraries for mapping canonical names of OpenConfig entities to platform specific implementations
Apache License 2.0
2 stars 4 forks source link

Basic usage example #34

Open nleiva opened 2 months ago

nleiva commented 2 months ago

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

lgomez9 commented 1 month ago

Hi Nicolas - taking over for Greg on this library.

Re: on your first question - I think naming is supposed to be entname, as you noted in your example.

Your example looks exactly as we'd expect users to interact with it.

nleiva commented 1 month ago

Thanks @lgomez9. Looking forward to collaborating on this.