added junos, updated screenos
[configmanager.git] / lib / screenos.plugin.php
index 30da607..20555d3 100644 (file)
@@ -1,60 +1,8 @@
 <?php 
 $HOST_TYPE["screenos"]["name"] = "Netscreen Screen OS";
-$HOST_TYPE["screenos"]["configform"] = "nsos_formFunction";
-$HOST_TYPE["screenos"]["postfunction"] = "nsos_postFunction";
 $HOST_TYPE["screenos"]["updateconfig"] = "nsos_updateConfig";
-$HOST_TYPE["screenos"]["detail"] = "nsos_detail";
 $HOST_TYPE["screenos"]["getconfig"] = "nsos_getConfigFromDB";
-
-function nsos_formFunction()
-{
-       ?>
-Note: If your router/firewall/device uses a one-time password, leave these blank and manually update from the
-home page<br>
-Name <input type="text" name="username"><br>
-Password <input type="password" name="password"><br>
-Method <select name="methodtype"><option value="ssh">SSH</option><option value="telnet">Telnet</option></select>
-       <?php
-}
-
-function nsos_postFunction()
-{
-       if($_REQUEST["password"] != "" && $_REQUEST["username"] != "") {
-               
-               $hip = $_REQUEST["hostip"];
-               $user = $_REQUEST["username"];
-               $pass = $_REQUEST["password"];
-               $config = nsos_getConfig($hip, $user, $pass);
-               $hconfig["username"] = $user;
-               $hconfig["password"] = $pass;
-               $lastupdate = time();
-               $upsched = $_REQUEST["upsched"];
-               db_updateData("hosts", "hostconfig", base64_encode(serialize($hconfig)), "hostip", "$hip");
-               db_updateData("hosts", "lastupdate", "$lastupdate", "hostip", "$hip");
-               db_updateData("hosts", "updateschedule", "$upsched", "hostip", "$hip");
-               db_insertData("configs", "$hip", "$lastupdate", base64_encode($config));
-               //db_createTable("configs", "hostip", "configtime", "configdata");
-               //db_createTable("hosts", "hostname", "hostip", "hosttype", "hostconfig", "lastupdate", "updateschedule");
-               //function db_updateData($tablename, $column, $newdata, $wherecol, $wheredata, $exact=true)
-               
-               echo "if the below is accurate, this has worked<br>";
-               
-               echo "Attempting first config grab, i see<br>";
-               echo "<pre>";
-               echo $config;
-               echo "</pre>";
-       } else {
-               echo "No username and password set, you can update manually from the home page\n";
-               $hconfig["username"] = "";
-               $hconfig["password"] = "";
-               db_updateData("hosts", "hostconfig", base64_encode(serialize($hconfig)), "hostip", "$hip");
-       }
-       
-       
-       echo "<pre>";
-       print_r($_REQUEST);
-       echo "</pre>";
-}
+$HOST_TYPE["screenos"]["needsenable"] = false;
 
 
 function nsos_getConfigFromDB($hip, $cid)
@@ -64,70 +12,11 @@ function nsos_getConfigFromDB($hip, $cid)
        return base64_decode($data[0]["configdata"]);
 }
 
-function nsos_detail($hip)
-{
-       $data = db_selectData("configs", "hostip", "$hip", "configtime desc");
-       
-       echo "<table border=\"1\">";
-       echo "<tr><th>Config Data</th><th>Compare</th></tr>";
-       foreach($data as $dstruct) {
-               //echo "<pre>";
-               //print_r($dstruct);
-               //echo "</pre>";
-               $dold = round((time()-$dstruct["configtime"])/86400);
-                               
-               $lupdate = strftime("%T %e %b %G", $dstruct["configtime"])." ($dold days old)";
-               $cid = $dstruct["configs_id"];
-               echo "<tr><td>$lupdate <a href=\"?action=getconfig&cid=$cid&hip=$hip\">Get</a> <a href=\"?action=downloadconfig&cid=$cid&hip=$hip\">Download</a></td><td>Tick</td></tr>";
-       }
-       echo "</table>";
-       
-}
-
 function nsos_updateConfig($hip, $hostconfig)
 {
-       $hconf = unserialize(base64_decode($hostconfig));
-       if($hconf["username"] == "" && !isset($_REQUEST["username"])) {
-               echo "No username/password data<br>";
-?>
-<form method="post" action="?action=update&hip=<?php echo $hip ?>">
-Name <input type="text" name="username"><br>
-Password <input type="password" name="password"><br>
-<input type="submit" name="Go" value="Go"><br>
-</form>
-<?php
-               return 0;
-       }
-       
-       if(isset($_REQUEST["username"])) {
-               $hconf["username"] = $_REQUEST["username"];
-               $hconf["password"] = $_REQUEST["password"];
-       }
-       
-       $lastconfig_n_d = db_getMaxValue("configs", "configs_id", "hostip", $hip);
-       $lastconfig_n = $lastconfig_n_d[0][0];
-       $lastconfig_d = db_selectData("configs", "configs_id", "$lastconfig_n");
-       $lastconfig = base64_decode($lastconfig_d[0]["configdata"]);
-       
-       $config = nsos_getConfig($hip, $hconf["username"], $hconf["password"]);
-       
-       if(md5($config) == md5($lastconfig)) {
-               echo "Retrieved config is same as previous one, ignoring<br>";
-               return 0;
-       }
-       
-       //error_log("getting config with ".$hconf["username"]." and ".$conf["password"]);
-       echo "Got config, saving it to db<br>";
-       $lastupdate = time();
-       db_updateData("hosts", "lastupdate", "$lastupdate", "hostip", "$hip");
-       db_insertData("configs", "$hip", "$lastupdate", base64_encode($config));
-
-       echo "Config is:<br><pre>";
-       echo $config;
-       echo "</pre>";
 }
 
-function nsos_getConfig($host, $username, $password)
+function nsos_getConfig($host, $username, $password, $enable)
 {
        return genericssh_ssh($host, $username, $password, "cli show configuration");
 }