im not actually shure...
[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 // pscp -scp -pw 'password' -l admin so-f2:ns_sys_config
26 function screenosisgay($host, $username, $password, $command)
27 {
28         $connector = ssh2_connect("$host");
29         error_log("attempting connect to $host with $username");
30         if($connector) {
31                 error_log("connector true");
32         } else {
33                 error_log("connector false");
34         }
35         ssh2_auth_password($connector, "$username", "$password");
36         $stream = ssh2_shell($connector, 'ansi');
37         fwrite($stream, PHP_EOL);
38         fwrite($stream, "set console page 0".PHP_EOL);
39         fwrite($stream, "get config".PHP_EOL);
40         fwrite($stream, PHP_EOL);
41         sleep(1);
42         stream_set_blocking($stream, true);
43         //fwrite($stream, "exit".PHP_EOL);
44         //fwrite($stream, "n".PHP_EOL);
45
46
47         $config = "";
48         $initline = "";
49         $haveinit = false;
50         while($buf = fgets($stream, 4096)) {
51                 flush();
52                 echo "got buf\n\"$buf\"\n";
53                 $initline = $buf;
54                 $config .= $buf;
55         }
56         fclose($stream);
57
58         return $config;
59 }
60
61
62
63 ?>