Skip to content

Commit

Permalink
group property reader: deactivate values inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
babos77 committed May 21, 2021
1 parent de3caa5 commit af61647
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 2 deletions.
55 changes: 54 additions & 1 deletion config/device-classes/generic/ekinops.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,57 @@ identify:
- type: modify
modify_method: regexSubmatch
regex: 'Release\s+([0-9\.]+)'
format: "$1"
format: "$1"

components:
interfaces:
count: 1.3.6.1.2.1.2.1.0
properties:
detection: snmpwalk
inherit_values: false
values:
ifIndex:
oid: 1.3.6.1.2.1.2.2.1.1
ifDescr:
oid: 1.3.6.1.2.1.2.2.1.2
ifType:
oid: 1.3.6.1.2.1.2.2.1.3
operators:
- type: modify
modify_method: map
mappings: ifType.yaml
ifPhysAddress:
oid: 1.3.6.1.2.1.2.2.1.6
use_raw_result: true
operators:
- type: modify
modify_method: regexSubmatch
regex: '(.{2})(.{2})(.{2})(.{2})(.{2})(.{2})'
format: "$1:$2:$3:$4:$5:$6"
return_on_mismatch: true
ifAdminStatus:
oid: 1.3.6.1.2.1.2.2.1.7
operators:
- type: modify
modify_method: map
ignore_on_mismatch: true
mappings:
"1": "up"
"2": "down"
"3": "testing"
ifOperStatus:
oid: 1.3.6.1.2.1.2.2.1.8
operators:
- type: modify
modify_method: map
ignore_on_mismatch: true
mappings:
"1": "up"
"2": "down"
"3": "testing"
"4": "unknown"
"5": "dormant"
"6": "notPresent"
"7": "lowerLayerDown"
ifName:
oid: 1.3.6.1.2.1.31.1.1.1.1
11 changes: 10 additions & 1 deletion core/communicator/deviceclass/device_class.go
Original file line number Diff line number Diff line change
Expand Up @@ -1558,8 +1558,17 @@ func interface2GroupPropertyReader(i interface{}, parentGroupPropertyReader grou
return nil, errors.New("oid reader is no list of oids")
}

inheritValuesFromParent := true
if b, ok := m["inherit_values"]; ok {
bb, ok := b.(bool)
if !ok {
return nil, errors.New("inherit_values needs to be a boolean")
}
inheritValuesFromParent = bb
}

//overwrite parent
if parentGroupPropertyReader != nil {
if inheritValuesFromParent && parentGroupPropertyReader != nil {
parentSNMPGroupPropertyReader, ok := parentGroupPropertyReader.(*snmpGroupPropertyReader)
if !ok {
return nil, errors.New("can't merge SNMP group property reader with property reader of different type")
Expand Down

0 comments on commit af61647

Please sign in to comment.