Browse Source

Add support for per-device overrides.

Joe Clarke 5 years ago
parent
commit
4e2fac275e
1 changed files with 12 additions and 0 deletions
  1. 12 0
      www/swreg/swreg.php

+ 12 - 0
www/swreg/swreg.php

@@ -220,6 +220,9 @@ try {
 $port_contents = "interface range {$port_type}{$start_port} - $max_ports\n";
 if (file_exists(PORT_TMPL_DIR.'/devices/'.$row['hostname'].'-ports.tmpl')) {
     $port_contents = file_get_contents(PORT_TMPL_DIR.'/devices/'.$row['hostname'].'-ports.tmpl');
+    if (file_exists(PORT_TMPL_DIR.'/device-overrides/'.$row['hostname'].'-ports.tmpl')) {
+        $port_contents .= file_get_contents(PORT_TMPL_DIR.'/device-overrides/'.$row['hostname'].'-ports.tmpl');
+    }
 } else {
     if (file_exists(PORT_TMPL_DIR.'/ports.tmpl')) {
         $port_contents .= file_get_contents(PORT_TMPL_DIR.'/ports.tmpl');
@@ -233,6 +236,9 @@ if (file_exists(PORT_TMPL_DIR.'/devices/'.$row['hostname'].'-ports.tmpl')) {
     if (file_exists(PORT_TMPL_DIR.'/DYNAMIC/'.$found_pid.'/ports.tmpl')) {
         $port_contents .= file_get_contents(PORT_TMPL_DIR.'/DYNAMIC/'.$found_pid.'/ports.tmpl');
     }
+    if (file_exists(PORT_TMPL_DIR.'/device-overrides/'.$row['hostname'].'-ports.tmpl')) {
+        $port_contents .= file_get_contents(PORT_TMPL_DIR.'/device-overrides/'.$row['hostname'].'-ports.tmpl');
+    }
 }
 
 $snmp_loc = $row['snmp_loc'];
@@ -254,6 +260,9 @@ if (file_exists(DEVICE_TMPL_DIR.'/device.tmpl')) {
 if (file_exists(DEVICE_TMPL_DIR.'/'.$found_pid.'/device.tmpl')) {
     $contents .= file_get_contents(DEVICE_TMPL_DIR.'/'.$found_pid.'/device.tmpl');
 }
+if (file_exists(DEVICE_TMP_DIR.'/device-override/'.$row['hostname'].'-device.tmpl')) {
+    $contents .= file_get_contents(DEVICE_TMP_DIR.'/device-overrides/'.$row['hostname'].'-device.tmpl');
+}
 $contents .= "end\n";
 
 $eem_contents = '';
@@ -263,6 +272,9 @@ if (file_exists(EEM_TMPL_DIR.'/eem.tmpl')) {
 if (file_exists(EEM_TMPL_DIR.'/'.$found_pid.'/eem.tmpl')) {
     $eem_contents .= file_get_contents(EEM_TMPL_DIR.'/'.$found_pid.'/eem.tmpl');
 }
+if (file_exists(EEM_TMPL_DIR.'/device-overrides/'.$row['hostname'].'-eem.tmpl')) {
+    $eem_contents .= file_get_contents(EEM_TMPL_DIR.'/device-overrides/'.$row['hostname'].'-eem.tmpl');
+}
 $contents = str_replace('%%EEM_CONFIG%%', $eem_contents, $contents);
 
 $vlan_contents = file_get_contents(VLAN_TMPL_DIR.'/'.strtolower($row['location']).'-vlan.tmpl');