XenServer Software Development Kit Guide 4.1.0

Overview of the XenServer API
12
3.3.3.1. Host storage configuration: PBDs
Let us start by considering the PBD class. A PBD_create(...) call takes a number of parameters including:
Parameter Description
host physical machine on which the PBD is available
SR the Storage Repository that the PBD connects to
device_config a string-to-string map that is provided to the host's SR-backend-driver,
containing the low-level parameters required to configure the physical storage
device(s) on which the SR is to be realized. The specific contents of the
device_config field depend on the type of the SR to which the PBD
is connected. (Executing xe sm-list will show a list of possible SR types;
the configuration field in this enumeration specifies the device_config
parameters that each SR type expects.)
For example, imagine we have an SR object s of type "nfs" (representing a directory on an NFS filer within
which VDIs are stored as VHD files); and let's say that we want a host, h, to be able to access s. In this
case we invoke PBD.create(...) specifying host h, SR s, and a value for the device_config parameter that
is the following map:
("server", "my_nfs_server.example.com"), ("serverpath", "/scratch/mysrs/sr1")
This tells the XenServer Host that SR s is accessible on host h, and further that to access SR s, the host
needs to mount the directory "/scratch/mysrs/sr1" on the NFS server named "my_nfs_server.example.com."
Like VBD objects, PBD objects also have a field called currently_attached. Storage repositories can be
attached and detached from a given host by invoking PBD.plug and PBD.unplug methods respectively.
3.3.3.2. Host networking configuration: PIFs
Host network configuration is specified by virtue of PIF objects. If a PIF object connects a network object,
n, to a host object h, then the network corresponding to n is bridged onto a physical interface (or a physical
interface plus a VLAN tag) specified by the fields of the PIF object.
For example, imagine a PIF object exists connecting host h to a network n, and that device field of the
PIF object is set to "eth0." This means that all packets on network n are bridged to the NIC in the host
corresponding to host network device "eth0."
3.4. Exporting and Importing VMs
VMs can be exported to a file and later imported to any XenServer Host. The export protocol is a simple
HTTP(S) GET, which should be performed on the master. Authorization is either standard HTTP basic
authentication, or if a session has already been obtained, this can be used. The VM to export is specified
either by UUID or by reference. To keep track of the export, a task can be created and passed in via its
reference. The request might result in a redirect if the VM's disks are only accessible on a slave.
The followwing arguments are passed on the command line:
Argument Description
session_id the reference of the session being used to authenticate; required only
when not using HTTP basic authentication
task_id the reference of the task object with which to keep track of the operation
ref the reference of the VM; required only if not using the UUID