commit | author | age
|
413d3b
|
1 |
<?php |
T |
2 |
|
|
3 |
$username = 'admin'; |
|
4 |
$password = 'admin'; |
|
5 |
|
|
6 |
$soap_location = 'http://localhost:8080/remote/index.php'; |
|
7 |
$soap_uri = 'http://localhost:8080/remote/'; |
|
8 |
|
|
9 |
|
|
10 |
$client = new SoapClient(null, array('location' => $soap_location, |
b1a6a5
|
11 |
'uri' => $soap_uri, |
MC |
12 |
'trace' => 1, |
|
13 |
'exceptions' => 1)); |
413d3b
|
14 |
|
T |
15 |
|
|
16 |
try { |
b1a6a5
|
17 |
if($session_id = $client->login($username, $password)) { |
413d3b
|
18 |
echo 'Logged successfull. Session ID:'.$session_id.'<br />'; |
T |
19 |
} |
b1a6a5
|
20 |
|
MC |
21 |
//* Params are optional for this function. If params are set, |
413d3b
|
22 |
//* then they override the template settings. |
T |
23 |
$params = array(); |
b1a6a5
|
24 |
|
413d3b
|
25 |
//* Set the function parameters. |
T |
26 |
$client_id = 0; |
|
27 |
$ostemplate_id = 3; |
|
28 |
$template_id = 3; |
b1a6a5
|
29 |
|
413d3b
|
30 |
$vm_id = $client->openvz_vm_add_from_template($session_id, $client_id, $ostemplate_id, $template_id, $params); |
T |
31 |
|
|
32 |
print_r($vm_id); |
|
33 |
echo "<br>"; |
b1a6a5
|
34 |
|
413d3b
|
35 |
if($client->logout($session_id)) { |
T |
36 |
echo 'Logged out.<br />'; |
|
37 |
} |
b1a6a5
|
38 |
|
MC |
39 |
|
413d3b
|
40 |
} catch (SoapFault $e) { |
T |
41 |
echo $client->__getLastResponse(); |
|
42 |
die('SOAP Error: '.$e->getMessage()); |
|
43 |
} |
|
44 |
|
|
45 |
?> |