-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetVMReferenceId.php
More file actions
36 lines (29 loc) · 1.34 KB
/
Copy pathGetVMReferenceId.php
File metadata and controls
36 lines (29 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
if (isset($_GET['VMName'])) {
$VMName = $_GET['VMName'];
}
// Opening an SSH connection
$connection3 = ssh2_connect('localhost', 22);
ssh2_auth_password($connection3, 'root', 'virtualsense');
//Passing commands to the SSH connection
$stream = ssh2_exec($connection3, "/root/scripts/xenserver/Gettest2.py");
$Master = ssh2_fetch_stream($stream,SSH2_STREAM_STDERR);
// Block Streaming to let the command finish (it will stop prematurely otherwise)
stream_set_blocking($stream, true);
// The command may not finish properly if the stream is not read to end
$Master = stream_get_contents($stream);
fclose($stream);
fwrite($handle, $Master);
// Opening an SSH connection
$connection = ssh2_connect($Master, 22);
ssh2_auth_password($connection, 'root', 'virtualsense')
//Passing commands to the SSH connection
$stream = ssh2_exec($connection, "/root/scripts/OpaqueRef.py $VMName");
$output = ssh2_fetch_stream($stream,SSH2_STREAM_STDERR);
// Block Streaming to let the command finish (it will stop prematurely otherwise)
stream_set_blocking($stream, true);
// The command may not finish properly if the stream is not read to end
$output = stream_get_contents($stream);
fclose($stream);
echo "<?xml version='1.0'?><results><result><code>$output</code><message></message></result></results>";
?>