Merge pull request #946 from f0o/issue-945

Add port-rewrite options
This commit is contained in:
Neil Lathwood
2015-05-09 22:46:05 +01:00
2 changed files with 26 additions and 0 deletions
+10
View File
@@ -322,6 +322,16 @@ by continuing the array.
`bad_iftype` is matched against the ifType value.
`bad_if_regexp` is matched against the ifDescr value as a regular expression.
#### Interfaces to be rewritten
```php
$config['rewrite_if']['cpu'] = 'Management Interface';
$config['rewrite_if_regexp']['/cpu /'] = 'Management ';
```
Entries defined in `rewrite_if` are being replaced completely.
Entries defined in `rewrite_if_regexp` only replace the match.
Matches are compared case-insensitive.
#### Storage configuration
```php
+16
View File
@@ -82,6 +82,22 @@ function ifLabel($interface, $device = NULL)
list($interface['label']) = explode("thomson", $interface['label']);
}
if( is_array($config['rewrite_if']) ) {
foreach( $config['rewrite_if'] as $src => $val ) {
if( stristr($interface['label'], $src) ) {
$interface['label'] = $val;
}
}
}
if( is_array($config['rewrite_if_regexp']) ) {
foreach( $config['rewrite_if_regexp'] as $reg => $val ) {
if( preg_match($reg."i", $interface['label']) ) {
$interface['label'] = preg_replace($reg."i",$val,$interface['label']);
}
}
}
return $interface;
}