-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from inexio/pre-release
Pre release
- Loading branch information
Showing
6 changed files
with
80 additions
and
1 deletion.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,4 +28,4 @@ | |
package doc | ||
|
||
// Version specifies the current version. | ||
const Version = "v0.5.2" | ||
const Version = "v0.5.3" |