Browse Source

Convert the EEM templates to be the same as others.

Joe Clarke 8 years ago
parent
commit
b0f08ebbd9

+ 0 - 10
templates/device-templates/device.tmpl

@@ -211,15 +211,5 @@ line vty 5 15
 event manager scheduler applet thread class default number 8
 %%EEM_CONFIG%%
 !
-event manager applet do-ssh
- event timer cron cron-entry "@reboot" maxrun 130
- action 0.5 wait 10
- action 1.0 cli command "enable"
- action 2.0 cli command "config t"
- action 3.0 cli command "crypto key generate rsa modulus 2048"
- action 4.0 cli command "no event manager applet do-ssh"
- action 5.0 cli command "end"
- action 6.0 cli command "write mem"
-!
 no exception crashinfo
 ntp server 63.231.220.15 source %%MGMT_VLAN%%

+ 0 - 0
templates/eem-templates/.keep_me


+ 4 - 0
templates/eem-templates/README

@@ -0,0 +1,4 @@
+If eem-templates directory contains a file called ``eem.tmpl'' then that file
+will be loaded first.  After that, if there is a sub-directory named
+after the PID, and that sub-directory contains a file named ``eem.tmpl'' it
+will be loaded and appended to the general EEM directives.

+ 0 - 0
templates/eem-config-3560cg.tmpl.in → templates/eem-templates/WS-C3560CG-8PC-S/eem.tmpl.in


+ 0 - 0
templates/eem-config-3750x.tmpl.in → templates/eem-templates/WS-C3750X/eem.tmpl.in


+ 1 - 5
www/swreg/swreg.inc.php

@@ -10,6 +10,7 @@ define('DEVICE_TMPL_DIR', TFTPBOOT . '/device-templates');
 define('DEVICE_CONFIG_DIR', TFTPBOOT . '/device-configs');
 define('DEVICE_TMP_DIR', TFTPBOOT . '/device-tmp');
 define('PORT_PROFILE_DIR', TFTPBOOT . '/port-profiles');
+define('EEM_TMPL_DIR', TFTPBOOT . '/eem-templates');
 define('FPING_PROGRAM', '/usr/local/sbin/fping');
 define('TOOL_NAME', 'CiscoLive Switch Registration Tool');
 define('PRIME_CRED_PROFILE', 'CLUS-creds');
@@ -65,11 +66,6 @@ $PORT_TYPES = array(
 	'WS-C3560CG-8PC-S' => 'GigabitEthernet',
 	'WS-C3750X'        => 'GigabitEthernet',
 );
-
-$EEM_CONFIG_FILES = array(
-	'WS-C3560CG-8PC-S' => 'eem-config-3560cg.tmpl',
-	'WS-C3750X'        => 'eem-config-3750x.tmpl',
-);
 # End PID arrays
 
 # Fill out PIDs mapping to number of ports.

+ 7 - 7
www/swreg/swreg.php

@@ -83,12 +83,6 @@ foreach ($ZTP_PIDS as $zpid) {
 			}
 			$image = $IMG_FILES[$zpid];
 		}
-		if (!isset($EEM_CONFIG_FILES[$zpid])) {
-			echo $not_configed;
-			$logger->emerg("\$EEM_CONFIG_FILES[$zpid] is not defined in swreg.inc.php!");
-			exit(1);
-		}
-		$eem_tmpl = $EEM_CONFIG_FILES[$zpid];
 		if (!isset($START_PORTS[$zpid])) {
 			echo $not_configed;
 			$logger->emerg("\$START_PORTS[$zpid] is not defined in swreg.inc.php!");
@@ -230,7 +224,13 @@ $vlan_contents = file_get_contents(VLAN_TMPL_DIR . "/" . strtolower($row['locati
 
 $contents = str_replace("%%VLAN_TMPL%%", $vlan_contents, $contents);
 
-$eem_contents = file_get_contents(TFTPBOOT . '/' . $eem_tmpl);
+$eem_contents = "";
+if (file_exists(EEM_TMPL_DIR . '/eem.tmpl')) {
+	$eem_contents = file_get_contents(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');
+}
 $contents = str_replace("%%EEM_CONFIG%%", $eem_contents, $contents);
 if (isset($VLAN_OVERRIDES) && isset($VLAN_OVERRIDES[$row['location']])) {
 	foreach ($VLAN_OVERRIDES[$row['location']] as $vn => $vi) {