Browse Source

Make SDM configurable.

The SDM profile shouldn't be hardcoded in the EEM boot script.
Instead, move this out as a configurable property.
Joe Clarke 5 years ago
parent
commit
0773fd419e
3 changed files with 23 additions and 15 deletions
  1. 14 15
      eem/tm_sw_autoconf.tcl
  2. 6 0
      www/swreg/swreg.inc.php
  3. 3 0
      www/swreg/swreg.php

+ 14 - 15
eem/tm_sw_autoconf.tcl

@@ -105,6 +105,7 @@ if { [::http::error $tok] != "" } {
 
 set image {}
 set config {}
+set sdm {}
 set pnp 0
 
 foreach line [split [::http::data $tok] "\n"] {
@@ -114,6 +115,9 @@ foreach line [split [::http::data $tok] "\n"] {
     if { [regexp {^Config: (\S+)} $line -> res] } {
         set config $res
     }
+    if { [regexp {^SDM: (\S+)} $line -> res] } {
+        set sdm $res
+    }
     if { [regexp {^PNP} $line] } {
 	      set pnp 1
     }
@@ -191,23 +195,18 @@ if { $config != {} } {
         error $result $errorInfo
     }
 
-    if { [catch {cli_exec $cli(fd) "config t"} result] } {
-        error $result $errorInfo
-    }
-
-    set failed 0
-    if { [catch {cli_exec $cli(fd) "sdm prefer advanced"} result] } {
-	set failed 1
-    }
+    if { $sdm != {} } {
+        if { [catch {cli_exec $cli(fd) "config t"} result] } {
+            error $result $errorInfo
+        }
 
-    if { $failed == 1 || [regexp {% Invalid input} $result] } {
-	if { [catch {cli_exec $cli(fd) "sdm prefer vlan"} result] } {
-	    error $result $errorInfo
-	}
-    }
+        if { [catch {cli_exec $cli(fd) "sdm prefer $sdm"} result] } {
+            error $result $errorInfo
+        }
 
-    if { [catch {cli_exec $cli(fd) "end"} result] } {
-        error $result $errorInfo
+        if { [catch {cli_exec $cli(fd) "end"} result] } {
+            error $result $errorInfo
+        }
     }
 
     if { [catch {cli_exec $cli(fd) "show switch | inc ^\\*"} result] } {

+ 6 - 0
www/swreg/swreg.inc.php

@@ -129,6 +129,12 @@ $PID_ALIASES = array(
     'WS-C3850-24U' => 'WS-C3850-24U-L',
 );
 
+// List any SDM profile preference here.
+// The profile will be configured at ZTP time.
+// If the PID is not here, no profile will be set.
+$SDM_PROFILES = array(
+);
+
 // Fill in VLAN mappings
 // VLAN macro will be the name with spaces turned to '_' and
 // all letters uppercase followed by _VLAN.

+ 3 - 0
www/swreg/swreg.php

@@ -370,6 +370,9 @@ if ($use_pnp) {
     $logger->info("Successfully provisioned switch $sn ($pid) {$row['hostname']} as a PnP device");
 } else {
     echo "Config: {$row['hostname']}-config.txt\r\n";
+    if (isset($SDM_PROFILES[$pid])) {
+        echo "SDM: {$SDM_PROFILES[$pid]}\r\n";
+    }
     if ($image !== null) {
         echo "Image: $image\r\n";
     }