From 22e26d82076b603ae9cff1deec7e64f593a77c6f Mon Sep 17 00:00:00 2001 From: mikameyer Date: Mon, 17 Jan 2022 10:47:54 +0100 Subject: [PATCH 1/2] ceraos added maxbitrate for Multi Carrier interfaces --- .../{ceraos-ip10.go => ceraos_ip10.go} | 0 config/codecommunicator/ceraos_ip20.go | 68 +++++++++++++++++++ config/codecommunicator/code_communicator.go | 2 + .../{timos-sas.go => timos_sas.go} | 0 config/deviceclass/generic/ceraos/ip20.yaml | 9 +++ 5 files changed, 79 insertions(+) rename config/codecommunicator/{ceraos-ip10.go => ceraos_ip10.go} (100%) create mode 100644 config/codecommunicator/ceraos_ip20.go rename config/codecommunicator/{timos-sas.go => timos_sas.go} (100%) create mode 100644 config/deviceclass/generic/ceraos/ip20.yaml diff --git a/config/codecommunicator/ceraos-ip10.go b/config/codecommunicator/ceraos_ip10.go similarity index 100% rename from config/codecommunicator/ceraos-ip10.go rename to config/codecommunicator/ceraos_ip10.go diff --git a/config/codecommunicator/ceraos_ip20.go b/config/codecommunicator/ceraos_ip20.go new file mode 100644 index 0000000..67613a0 --- /dev/null +++ b/config/codecommunicator/ceraos_ip20.go @@ -0,0 +1,68 @@ +package codecommunicator + +import ( + "context" + "github.com/inexio/thola/internal/device" + "github.com/inexio/thola/internal/deviceclass/groupproperty" + "github.com/rs/zerolog/log" + "strings" +) + +type ceraosIP20Communicator struct { + codeCommunicator +} + +// GetInterfaces returns the interfaces of ceraos/ip20 devices. +func (c *ceraosIP20Communicator) GetInterfaces(ctx context.Context, filter ...groupproperty.Filter) ([]device.Interface, error) { + interfaces, err := c.deviceClass.GetInterfaces(ctx, filter...) + if err != nil { + return nil, err + } + + model, err := c.deviceClass.GetModel(ctx) + if err != nil { + log.Ctx(ctx).Debug().Err(err).Msg("failed to get model of IP20 device") + return interfaces, nil + } + if !strings.HasSuffix(model, "2 radio") { + return interfaces, nil + } + + var maxbitrateIn *uint64 + var maxbitrateOut *uint64 + for _, interf := range interfaces { + if interf.Radio != nil && interf.Radio.MaxbitrateIn != nil { + rate := *interf.Radio.MaxbitrateIn + if maxbitrateIn != nil { + rate += *maxbitrateIn + } + maxbitrateIn = &rate + } + if interf.Radio != nil && interf.Radio.MaxbitrateOut != nil { + rate := *interf.Radio.MaxbitrateOut + if maxbitrateOut != nil { + rate += *maxbitrateOut + } + maxbitrateOut = &rate + } + } + + if maxbitrateIn != nil || maxbitrateOut != nil { + for i, interf := range interfaces { + if interf.IfName != nil && strings.HasPrefix(*interf.IfName, "Multi Carrier ABC") { + if interf.Radio != nil { + interfaces[i].Radio.MaxbitrateIn = maxbitrateIn + interfaces[i].Radio.MaxbitrateIn = maxbitrateOut + } else { + interfaces[i].Radio = &device.RadioInterface{ + MaxbitrateIn: maxbitrateIn, + MaxbitrateOut: maxbitrateOut, + } + } + } + } + return filterInterfaces(ctx, interfaces, filter) + } + + return interfaces, nil +} diff --git a/config/codecommunicator/code_communicator.go b/config/codecommunicator/code_communicator.go index e7bdcd7..9bf6b7a 100644 --- a/config/codecommunicator/code_communicator.go +++ b/config/codecommunicator/code_communicator.go @@ -28,6 +28,8 @@ func GetCodeCommunicator(deviceClass communicator.Communicator, parentNetworkDev switch classIdentifier { case "ceraos/ip10": return &ceraosIP10Communicator{base}, nil + case "ceraos/ip20": + return &ceraosIP20Communicator{base}, nil case "powerone/acc": return &poweroneACCCommunicator{base}, nil case "powerone/pcc": diff --git a/config/codecommunicator/timos-sas.go b/config/codecommunicator/timos_sas.go similarity index 100% rename from config/codecommunicator/timos-sas.go rename to config/codecommunicator/timos_sas.go diff --git a/config/deviceclass/generic/ceraos/ip20.yaml b/config/deviceclass/generic/ceraos/ip20.yaml new file mode 100644 index 0000000..777a2b5 --- /dev/null +++ b/config/deviceclass/generic/ceraos/ip20.yaml @@ -0,0 +1,9 @@ +name: ip20 + +match: + conditions: + - match_mode: startsWith + type: SysObjectID + values: + - .1.3.6.1.4.1.2281.1.20 + logical_operator: OR \ No newline at end of file From b2c83dcba9df48129fdba22cf4f722dc33fa5493 Mon Sep 17 00:00:00 2001 From: mikameyer Date: Mon, 17 Jan 2022 14:36:01 +0100 Subject: [PATCH 2/2] bump version --- doc/doc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/doc.go b/doc/doc.go index 7818a6b..d419d75 100644 --- a/doc/doc.go +++ b/doc/doc.go @@ -28,4 +28,4 @@ package doc // Version specifies the current version. -const Version = "v0.5.2" +const Version = "v0.5.3"