|
| 1 | +--- |
| 2 | +title: XenAPI Basics |
| 3 | +layout: default |
| 4 | +--- |
| 5 | + |
| 6 | +This document contains a description of the Xen Management API – an interface for |
| 7 | +remotely configuring and controlling virtualised guests running on a |
| 8 | +Xen-enabled host. |
| 9 | + |
| 10 | +The XenAPI is presented here as a set of Remote Procedure Calls, with a wire |
| 11 | +format based upon [XML-RPC](http://xmlrpc.scripting.com). |
| 12 | +No specific language bindings are prescribed, |
| 13 | +although examples will be given in the python programming language. |
| 14 | + |
| 15 | +Although we adopt some terminology from object-oriented programming, |
| 16 | +future client language bindings may or may not be object oriented. |
| 17 | +The API reference uses the terminology _classes_ and _objects_. |
| 18 | +For our purposes a _class_ is simply a hierarchical namespace; |
| 19 | +an _object_ is an instance of a class with its fields set to |
| 20 | +specific values. Objects are persistent and exist on the server-side. |
| 21 | +Clients may obtain opaque references to these server-side objects and then |
| 22 | +access their fields via get/set RPCs. |
| 23 | + |
| 24 | +For each class we specify a list of fields along with their _types_ and _qualifiers_. A |
| 25 | +qualifier is one of: |
| 26 | + |
| 27 | +- _RO/runtime_: the field is Read |
| 28 | +Only. Furthermore, its value is automatically computed at runtime. |
| 29 | +For example: current CPU load and disk IO throughput. |
| 30 | +- _RO/constructor_: the field must be manually set |
| 31 | +when a new object is created, but is then Read Only for |
| 32 | +the duration of the object's life. |
| 33 | +For example, the maximum memory addressable by a guest is set |
| 34 | +before the guest boots. |
| 35 | +- _RW_: the field is Read/Write. For example, the name of a VM. |
| 36 | + |
| 37 | +Types |
| 38 | +----- |
| 39 | + |
| 40 | +The following types are used to specify methods and fields in the API Reference: |
| 41 | + |
| 42 | +- `string`: Text strings. |
| 43 | +- `int`: 64-bit integers. |
| 44 | +- `float`: IEEE double-precision floating-point numbers. |
| 45 | +- `bool`: Boolean. |
| 46 | +- `datetime`: Date and timestamp. |
| 47 | +- `c ref`: Reference to an object of class `c`. |
| 48 | +- `t set`: Arbitrary-length set of values of type `t`. |
| 49 | +- `(k → v) map`: Mapping from values of type `k` to values of type `v`. |
| 50 | +- `e enum`: Enumeration type with name `e`. Enums are defined in the API Reference together with classes that use them. |
| 51 | + |
| 52 | +Note that there are a number of cases where `ref`s are _doubly |
| 53 | +linked_ – e.g. a VM has a field called `VIFs` of type |
| 54 | +`VIF ref set`; this field lists |
| 55 | +the network interfaces attached to a particular VM. Similarly, the VIF |
| 56 | +class has a field called `VM` of type `VM ref` which references the VM to which the interface is connected. |
| 57 | +These two fields are _bound together_, in the sense that |
| 58 | +creating a new VIF causes the `VIFs` field of the corresponding |
| 59 | +VM object to be updated automatically. |
| 60 | + |
| 61 | +The API reference explicitly lists the fields that are |
| 62 | +bound together in this way. It also contains a diagram that shows |
| 63 | +relationships between classes. In this diagram an edge signifies the |
| 64 | +existance of a pair of fields that are bound together, using standard |
| 65 | +crows-foot notation to signify the type of relationship (e.g. |
| 66 | +one-many, many-many). |
| 67 | + |
| 68 | +RPCs associated with fields |
| 69 | +--------------------------- |
| 70 | + |
| 71 | +Each field, `f`, has an RPC accessor associated with it |
| 72 | +that returns `f`'s value: |
| 73 | + |
| 74 | +- `get_f (r)`: Takes a `ref`, `r`, that refers to an object and returns the value of `f`. |
| 75 | + |
| 76 | +Each field, `f`, with attribute `RW` and whose outermost type is `set` has the following |
| 77 | +additional RPCs associated with it: |
| 78 | + |
| 79 | +- `add_f (r, v)`: Adds a new element `v` to the set. Since sets cannot contain duplicate values this operation has no action in the case |
| 80 | +that `v` was already in the set. |
| 81 | + |
| 82 | +- `remove_f (r, v)`: Removes element `v` from the set. |
| 83 | + |
| 84 | +Each field, `f`, with attribute RW and whose outermost type is `map` has the following |
| 85 | +additional RPCs associated with it: |
| 86 | + |
| 87 | +- `add_to_f (r, k, v)`: Adds new pair `(k → v)` to the mapping stored in `f` in object `r`. Attempting to add a new pair for duplicate |
| 88 | +key, `k`, fails with an `MAP_DUPLICATE_KEY` error. |
| 89 | +- `remove_from_f (r, k)`: Removes the pair with key `k` from the mapping stored in `f` in object `r`. |
| 90 | + |
| 91 | +Each field whose outermost type is neither `set` nor `map`, |
| 92 | +but whose attribute is RW has an RPC accessor associated with it |
| 93 | +that sets its value: |
| 94 | + |
| 95 | +- `set_f (r, v)`: Sets field `f` on object `r` to value `v`. |
| 96 | + |
| 97 | +RPCs associated with classes |
| 98 | +---------------------------- |
| 99 | + |
| 100 | +- Most classes have a _constructor_ RPC named `create` that |
| 101 | +takes as parameters all fields marked RW and |
| 102 | +RO/constructor. The result of this RPC is that a new _persistent_ object is |
| 103 | +created on the server-side with the specified field values. |
| 104 | +- Each class has a `get_by_uuid (uuid)` RPC that returns the object |
| 105 | +of that class that has the specified UUID. |
| 106 | +- Each class that has a `name_label` field has a `get_by_name_label (name_label)` RPC that returns a set of objects of that |
| 107 | +class that have the specified `name_label`. |
| 108 | +- Most classes have a `destroy (r)` RPC that explicitly deletes the persistent object specified by `r` from the system. This is a |
| 109 | +non-cascading delete – if the object being removed is referenced by another |
| 110 | +object then the `destroy` call will fail. |
| 111 | + |
| 112 | +Additional RPCs |
| 113 | +--------------- |
| 114 | + |
| 115 | +As well as the RPCs enumerated above, most classes have additional RPCs |
| 116 | +associated with them. For example, the VM class has RPCs for cloning, |
| 117 | +suspending, starting etc. Such additional RPCs are described explicitly |
| 118 | +in the API reference. |
0 commit comments