1cf491443eff760a10aa85e245f2ecea54fe32ae
[configmanager.git] / lib / screenos.plugin.php
1 <?php 
2 $HOST_TYPE["screenos"]["name"] = "Netscreen Screen OS";
3 $HOST_TYPE["screenos"]["updateconfig"] = "nsos_updateConfig";
4 $HOST_TYPE["screenos"]["getconfig"] = "nsos_getConfigFromDB";
5 $HOST_TYPE["screenos"]["needsenable"] = false;
6
7
8 function nsos_getConfigFromDB($hip, $cid)
9 {
10         $data = db_selectData("configs", "configs_id", "$cid");
11         
12         return base64_decode($data[0]["configdata"]);
13 }
14
15 function nsos_updateConfig($hip, $hostconfig)
16 {
17 }
18
19 function nsos_getConfig($host, $username, $password, $enable)
20 {
21         return genericssh_ssh($host, $username, $password, "cli show configuration");
22 }
23
24 // remembver this:
25 function screenosisgay($host, $username, $password, $command)
26 {
27         $connector = ssh2_connect("$host");
28         error_log("attempting connect to $host with $username");
29         if($connector) {
30                 error_log("connector true");
31         } else {
32                 error_log("connector false");
33         }
34         ssh2_auth_password($connector, "$username", "$password");
35         $stream = ssh2_shell($connector, 'ansi');
36         fwrite($stream, PHP_EOL);
37         fwrite($stream, "set console page 0".PHP_EOL);
38         fwrite($stream, "get config".PHP_EOL);
39         fwrite($stream, PHP_EOL);
40         sleep(1);
41         stream_set_blocking($stream, true);
42         //fwrite($stream, "exit".PHP_EOL);
43         //fwrite($stream, "n".PHP_EOL);
44
45
46         $config = "";
47         $initline = "";
48         $haveinit = false;
49         while($buf = fgets($stream, 4096)) {
50                 flush();
51                 echo "got buf\n\"$buf\"\n";
52                 $initline = $buf;
53                 $config .= $buf;
54         }
55         fclose($stream);
56
57         return $config;
58 }
59
60
61
62 ?>