Skip to content

Commit

Permalink
Merge pull request #95 from inexio/pre-release
Browse files Browse the repository at this point in the history
Pre release
  • Loading branch information
TheFireMike authored Jan 17, 2022
2 parents f68468a + b2c83dc commit 23c55ae
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 1 deletion.
File renamed without changes.
68 changes: 68 additions & 0 deletions config/codecommunicator/ceraos_ip20.go
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 2 additions & 0 deletions config/codecommunicator/code_communicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
File renamed without changes.
9 changes: 9 additions & 0 deletions config/deviceclass/generic/ceraos/ip20.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion doc/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@
package doc

// Version specifies the current version.
const Version = "v0.5.2"
const Version = "v0.5.3"

0 comments on commit 23c55ae

Please sign in to comment.