From 67c5482272acca1e1d1075fac8b489cc312ee897 Mon Sep 17 00:00:00 2001 From: Emanuele Fia Date: Wed, 1 Mar 2023 14:13:52 +0100 Subject: New juniper format Signed-off-by: Emanuele Fia --- dhcpv4/ztpv4/ztp.go | 10 ++++++++++ dhcpv4/ztpv4/ztp_test.go | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/dhcpv4/ztpv4/ztp.go b/dhcpv4/ztpv4/ztp.go index ecb63c6..8ab3a8e 100644 --- a/dhcpv4/ztpv4/ztp.go +++ b/dhcpv4/ztpv4/ztp.go @@ -68,6 +68,16 @@ func parseClassIdentifier(packet *dhcpv4.DHCPv4) (*VendorData, error) { vd.VendorName = p[0] return vd, nil + // Juniper:tttt-ttt:DN817 + case strings.HasPrefix(vc, "Juniper:"): + p := strings.Split(vc, ":") + if len(p) == 3 { + vd.VendorName = p[0] + vd.Model = p[1] + vd.Serial = p[2] + return vd, nil + } + return nil, fmt.Errorf("%w got '%s'", errVendorOptionMalformed, vc) // For Ciena the class identifier (opt 60) is written in the following format: // {vendor iana code}-{product}-{type} diff --git a/dhcpv4/ztpv4/ztp_test.go b/dhcpv4/ztpv4/ztp_test.go index 5d8ae8d..8210b12 100644 --- a/dhcpv4/ztpv4/ztp_test.go +++ b/dhcpv4/ztpv4/ztp_test.go @@ -41,6 +41,16 @@ func TestParseClassIdentifier(t *testing.T) { want: &VendorData{VendorName: "Juniper", Model: "qfx10008", Serial: "DE123"}, }, {name: "juniperNoSerial", vc: "Juniper-qfx10008", fail: true}, + { + name: "juniperHostnameSerialv2", + vc: "Juniper:ttttt-ttt:D12345", + want: &VendorData{VendorName: "Juniper", Model: "ttttt-ttt", Serial: "D12345"}, + }, + { + name: "juniperHostnameSerialv2Invalid", + vc: "Juniper:1", + fail: true, + }, { name: "zpe", vc: "ZPESystems:NSC:001234567", -- cgit v1.2.3