XenServer Software Development Kit Guide 4.1.0

Using the API
18
Dependencies:• XML-RPC library (libxml2.so on GNU Linux)
Curl library (libcurl2.so)
One simple example is included within the SDK called test_vm_ops. The example demonstrates how to
query the capabilities of a host, create a VM, attach a fresh blank disk image to the VM and then perform
various powercycle operations.
4.2.2. C#
The C# bindings are contained within the directory /SDK/client-examples/csharp/XenSdk.net and
include project files suitable for building under Microsoft Visual Studio. Every API object is associated with
one C# file; for example the functions implementing the VM operations are contained within the file VM.cs.
C# binding dependencies
Platform
supported:
Windows with .NET version 2.0
Library: The language binding is generated as a Dynamic Link Library Xenapi.dll that is linked by
C# programs
Dependencies:CookComputing.XMLRpcV2.dll is needed for the xenapi.dll to be able to communicate
with the xml-rpc server.
Two simple examples are included with the C# bindings in the directory /SDK/client-exam-
ples/csharp/XenSdk.net:
VM-Lifecycle: logs into a XenServer Host, lists all the VM records, filters out the templates, clones a
VM from one template, configures the name and description of the VM before finally power-cycling the
VM; and
Monitor: logs into a XenServer Host, queries properties of a host, lists all Storage Repositories, lists all
VMs and prints various attributes.
4.2.3. Python
The python bindings are contained within a single file: /SDK/client-examples/python/XenAPI.py.
Python binding dependencies
Platform
supported:
Linux
Library: XenAPI.py
Dependencies:None
The SDK includes 7 python examples:
fixpbds.py: reconfigures the settings used to access shared storage;
install.py: installs a Debian VM, connects it to a network, starts it up and waits for it to report its IP address;
license.py: uploads a fresh license to a XenServer Host;