Procurve hardware description cleanup (#14007)

* Procurve hardware description cleanup
Include part number and other details where available
Covers 100% of known sysDescr
Adds Aruba Instant On parsing
adds string replacements for OS fields

Could use hardware: ENTITY-MIB::entPhysicalDescr.1, but strings contain a lot of fluff and some are just "HP", I leave that for another PR

* restore .gitignore.........

* less specific

* Change regex cosmetically
This commit is contained in:
Tony Murray 2022-06-07 02:27:32 -05:00 committed by GitHub
parent 82be234bae
commit b8f2002150
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 162 additions and 19 deletions

View File

@ -81,6 +81,8 @@ trait YamlOSDiscovery
: $value;
}
}
$this->replaceStringsInFields($device, $os_yaml);
}
public function fetchLocation(): Location
@ -158,4 +160,17 @@ trait YamlOSDiscovery
return false;
}
private function replaceStringsInFields(Device $device, array $os_yaml): void
{
foreach ($this->osFields as $field) {
foreach ($os_yaml["{$field}_replace"] ?? [] as $replacements) {
if (is_array($replacements) && count($replacements) == 2) {
$device->$field = str_replace($replacements[0], $replacements[1], $device->$field);
} elseif (is_string($replacements)) {
$device->$field = str_replace($replacements, '', $device->$field);
}
}
}
}
}

View File

@ -160,6 +160,7 @@ more complex collection is required.
- `<field>` specify an oid or list of oids to attempt to pull the data from, the first non-empty response will be used
- `<field>_regex` parse the value out of the returned oid data, must use a named group
- `<field>_template` combine multiple oid results together to create a final string value. The result is trimmed.
- `<field>_replace` An array of replacements ['find', 'replace'] or strings to remove
- `hardware_mib` MIB used to translate sysObjectID to get hardware. hardware_regex can process the result.
```yaml

View File

@ -16,14 +16,19 @@ modules:
type: hpGlobal
os:
sysDescr_regex:
- '/( (?<hardware>E?\d{4,}\S*)[^,]*)?, revision (?<version>[^ ,]+)/'
- '/PROCURVE (?<hardware>.*) - (?<version>.*)/'
- '/(HPE OfficeConnect Switch|HP) (?<hardware>[\d]+[\ \-]\S+).*(?<version>P\S[0-9\.]+)/'
- '/(HP ProCurve) (?<hardware>\d+\S?).*(?<version>P[1-9\.]+)/'
- '/^(Aruba|ProCurve|HP) (?<hardware>[^,]+), revision (?<version>[^ ,]+)/'
- '/^(HPE OfficeConnect Switch|HP ProCurve|HP) (?<hardware>[^,]*), (?<version>P\S[0-9\.]+)/'
- '/^Aruba Instant On (?<hardware>[^,]+), InstantOn_\d+_(?<version>[0-9\.]+)/'
- '/^PROCURVE (?<hardware>.*) - (?<version>.*)$/'
- '/^(?<hardware>GbE2c)/'
version:
- NETSWITCH-MIB::hpSwitchOsVersion.0
- HP-SN-AGENT-MIB::snAgImgVer.0
serial: SEMI-MIB::hpHttpMgSerialNumber.0
hardware_replace:
- [' ', ' ']
- ' Switch'
- ' Stack'
processors:
data:
-

View File

@ -120,7 +120,11 @@
},
"location_template": {
"type": "string"
}
},
"version_replace": {"$ref": "#/definitions/os_replacements"},
"hardware_replace": {"$ref": "#/definitions/os_replacements"},
"features_replace": {"$ref": "#/definitions/os_replacements"},
"serial_replace": {"$ref": "#/definitions/os_replacements"}
},
"additionalProperties": false
},
@ -469,6 +473,24 @@
"data"
]
},
"os_replacements": {
"type": "array",
"items": {
"oneOf": [
{
"type": "array",
"items": {
"type": "string"
},
"minItems": 2,
"maxItems": 2
},
{
"type": "string"
}
]
}
},
"skip_values": {
"anyOf": [
{

View File

@ -549,7 +549,7 @@
"sysDescr": "HP Stack, revision KA.15.03.3004, ROM KA.15.05 (/sw/code/build/tam(KA_15_03))",
"sysContact": "<private>",
"version": "KA.15.03.3004",
"hardware": "",
"hardware": "Stack",
"features": null,
"os": "procurve",
"type": "network",

View File

@ -3,12 +3,12 @@
"discovery": {
"devices": [
{
"sysName": "",
"sysName": null,
"sysObjectID": ".1.3.6.1.4.1.11.2.3.7.11.131",
"sysDescr": "HP J9625A 2620-24-PoEP Switch, revision RA.16.02.0012, ROM RA.15.13 (/ws/swbuildm/rel_spokane_qaoff/code/build/xform(swbuildm_rel_spokane_qaoff_rel_spokane))",
"sysContact": null,
"version": "RA.16.02.0012",
"hardware": "2620-24-PoEP",
"hardware": "J9625A 2620-24-PoEP",
"features": null,
"os": "procurve",
"type": "network",

View File

@ -0,0 +1,23 @@
{
"os": {
"discovery": {
"devices": [
{
"sysName": null,
"sysObjectID": ".1.3.6.1.4.1.11.2.3.7.11.134",
"sysDescr": "HP V1810-48G, PK.1.38, eCos-2.0, CFE-3.8",
"sysContact": null,
"version": "PK.1.38",
"hardware": "V1810-48G",
"features": null,
"os": "procurve",
"type": "network",
"serial": null,
"icon": "hpe.svg",
"location": null
}
]
},
"poller": "matches discovery"
}
}

View File

@ -3,12 +3,12 @@
"discovery": {
"devices": [
{
"sysName": "",
"sysName": null,
"sysObjectID": ".1.3.6.1.4.1.11.2.3.7.11.151",
"sysDescr": "HP 1810-24G, PL.1.9, eCos-3.0, 1_12_8-customized-h",
"sysContact": null,
"version": "PL.1.9",
"hardware": "1810-24G,",
"hardware": "1810-24G",
"features": null,
"os": "procurve",
"type": "network",

View File

@ -3,12 +3,12 @@
"discovery": {
"devices": [
{
"sysName": "",
"sysName": null,
"sysObjectID": ".1.3.6.1.4.1.11.2.3.7.11.167",
"sysDescr": "HP 1820-8G Switch J9979A, PT.01.14, Linux 3.6.5-79c95a77, U-Boot 2012.10-00116-g3ab515c (Jul 30 2014 - 10:52:01)",
"sysContact": null,
"version": "PT.01.14",
"hardware": "1820-8G",
"hardware": "1820-8G J9979A",
"features": null,
"os": "procurve",
"type": "network",

View File

@ -3,12 +3,12 @@
"discovery": {
"devices": [
{
"sysName": "",
"sysName": null,
"sysObjectID": ".1.3.6.1.4.1.11.2.3.7.11.167",
"sysDescr": "HPE OfficeConnect Switch 1820 8G J9979A, PT.02.01, Linux 3.6.5-79c95a77, U-Boot 2012.10-00116-g3ab515c (Jul 30 2014 - 10:52:01)",
"sysContact": null,
"version": "PT.02.01",
"hardware": "1820 8G",
"hardware": "1820 8G J9979A",
"features": null,
"os": "procurve",
"type": "network",

View File

@ -0,0 +1,23 @@
{
"os": {
"discovery": {
"devices": [
{
"sysName": null,
"sysObjectID": ".1.3.6.1.4.1.11.2.3.7.11.184",
"sysDescr": "HPE OfficeConnect Switch 1920S 24G 2SFP JL381A, PD.01.05, Linux 3.6.5-ac96795c, U-Boot 2012.10-00118-g3773021 (Oct 11 2016 - 15:39:54)",
"sysContact": null,
"version": "PD.01.05",
"hardware": "1920S 24G 2SFP JL381A",
"features": null,
"os": "procurve",
"type": "network",
"serial": null,
"icon": "hpe.svg",
"location": null
}
]
},
"poller": "matches discovery"
}
}

View File

@ -0,0 +1,23 @@
{
"os": {
"discovery": {
"devices": [
{
"sysName": null,
"sysObjectID": ".1.3.6.1.4.1.11.2.3.7.11.200",
"sysDescr": "Aruba Instant On 1930 48G Class4 PoE 4SFP/SFP 370W Switch JL686A, InstantOn_1930_1.0.5.0 (139), Linux 4.4.120, U-Boot 2013.01 (V1.0.1.29)",
"sysContact": null,
"version": "1.0.5.0",
"hardware": "1930 48G Class4 PoE 4SFP/SFP 370W JL686A",
"features": null,
"os": "procurve",
"type": "network",
"serial": null,
"icon": "hpe.svg",
"location": null
}
]
},
"poller": "matches discovery"
}
}

View File

@ -549,7 +549,7 @@
"sysDescr": "HP Stack, revision KA.15.03.3004, ROM KA.15.05 (/sw/code/build/tam(KA_15_03))",
"sysContact": "<private>",
"version": "KA.15.03.3004",
"hardware": "",
"hardware": "Stack",
"features": null,
"os": "procurve",
"type": "network",

View File

@ -0,0 +1,23 @@
{
"os": {
"discovery": {
"devices": [
{
"sysName": null,
"sysObjectID": ".1.3.6.1.4.1.11.2.3.7.11.33.4.1.1",
"sysDescr": "GbE2c L2/L3 Ethernet Blade Switch for HP c-Class BladeSystem",
"sysContact": null,
"version": null,
"hardware": "GbE2c",
"features": null,
"os": "procurve",
"type": "network",
"serial": null,
"icon": "hpe.svg",
"location": null
}
]
},
"poller": "matches discovery"
}
}

View File

@ -3,12 +3,12 @@
"discovery": {
"devices": [
{
"sysName": "",
"sysName": null,
"sysObjectID": ".1.3.6.1.4.1.11.2.3.7.11.50",
"sysDescr": "ProCurve J8697A Switch 5406zl, revision K.15.04.0007, ROM K.15.13 (/sw/code/build/btm(K_15_04))",
"sysContact": null,
"version": "K.15.04.0007",
"hardware": "5406zl",
"hardware": "J8697A 5406zl",
"features": null,
"os": "procurve",
"type": "network",

View File

@ -3,7 +3,7 @@
"discovery": {
"devices": [
{
"sysName": "",
"sysName": null,
"sysObjectID": ".1.3.6.1.4.1.11.2.3.7.11.66",
"sysDescr": "PROCURVE J9029A - PA.03.10",
"sysContact": null,

View File

@ -8,7 +8,7 @@
"sysDescr": "HP J9146A E2910al-24G-PoE Switch, revision W.15.08.0012, ROM W.14.06 (/ws/swbuildm/W_rel_galt_qaoff/code/build/sbm(W_rel_galt_qaoff)) (Formerly ProCurve)",
"sysContact": "<private>",
"version": "W.15.08.0012",
"hardware": "E2910al-24G-PoE",
"hardware": "J9146A E2910al-24G-PoE",
"features": null,
"os": "procurve",
"type": "network",

View File

@ -0,0 +1,2 @@
1.3.6.1.2.1.1.1.0|4|HP V1810-48G, PK.1.38, eCos-2.0, CFE-3.8
1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.11.2.3.7.11.134

View File

@ -0,0 +1,2 @@
1.3.6.1.2.1.1.1.0|4|HPE OfficeConnect Switch 1920S 24G 2SFP JL381A, PD.01.05, Linux 3.6.5-ac96795c, U-Boot 2012.10-00118-g3773021 (Oct 11 2016 - 15:39:54)
1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.11.2.3.7.11.184

View File

@ -0,0 +1,2 @@
1.3.6.1.2.1.1.1.0|4|Aruba Instant On 1930 48G Class4 PoE 4SFP/SFP 370W Switch JL686A, InstantOn_1930_1.0.5.0 (139), Linux 4.4.120, U-Boot 2013.01 (V1.0.1.29)
1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.11.2.3.7.11.200

View File

@ -0,0 +1,2 @@
1.3.6.1.2.1.1.1.0|4|GbE2c L2/L3 Ethernet Blade Switch for HP c-Class BladeSystem
1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.11.2.3.7.11.33.4.1.1