-
Notifications
You must be signed in to change notification settings - Fork 16
/
example.php
39 lines (26 loc) · 1.14 KB
/
example.php
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
37
38
39
<?
include('xenapi.php');
$url = "https://10.0.0.1"; /* URL of the Citrix XenSerer Xapi */
$login = "root"; /* login/user for the citrix box */
$password = "password"; /* password for the user */
/* Establish session with Xenserver */
$xenserver = new XenApi($url, $login, $password);
/* Once sucessfully logged in - any method (valid or not) is passed to the XenServer.
Replace the first period (.) of the method with a underscore (_) - because PHP doesnt like
periods in the function names.
All the methods (other then logging in) require passing the session_id as the first parameter,
however this is done automatically - so you do not need to pass it.
For example, to do VM.get_all(session_id) and get all the vms as an array, then get/print the details of each
using VM.get_record(session_id, self) (self = VM object):
*/
$vms_array = $xenserver->VM_get_all();
foreach ($vms_array as $vm) {
$record = $xenserver->VM_get_record($vm);
print_r($record);
}
/*
For parameters/usage, check out:
http://docs.vmd.citrix.com/XenServer/5.5.0/1.0/en_gb/api/docs/html/browser.html
To see how parametes are returned, print_r() is your friend :)
*/
?>