XAPIcall is using theXml-rpcthe protocol is sent over the network to the installationXenServeron the host. XAPIAn object's reference does not guarantee the object's persistent identifier, and the reference does not allow the object to be compared equally. Two references to the same object are not guaranteed to be the same text. ObjectUUID(universally uniqueidentifierThe purpose of the Universal Unique identification code) is to permanently name the customer by comparing the object'sUUIDstring test Equality. XenServerof theXAPIprovideUUIDand opaque references, each class contains aUUIDfield.
XenServer APIis based onXml-rpcprotocol for communication. Xml-rpcis inInterneta specification for implementing a remote method call on aHTTPas a transport protocol, use theXMLthe transport principal that is requested as a message. Xml-rpcwill aXMLThe format of the message body asHTTP POSTThe request is sent to the server, which includes the name, the program that runs the service, and the input parameters that the server executes toXMLformat is returned, and its principle:
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/82/77/wKiom1dWPmTgi61bAAB6Aj1n9-g233.png "title=" 3.png " Width= "672" height= "257" border= "0" hspace= "0" vspace= "0" style= "WIDTH:672PX;HEIGHT:257PX;" alt= " Wkiom1dwpmtgi61baab6aj1n9-g233.png "/>
through XenServer XAPI , users can manage virtual machines, storage, networking, host configuration, and XenServer pool. The steps to invoke the XenServer API are as follows :
( 1 ) Select a transport level
the following two types of transmissions can be emitted API called :
( 2 ) authentication and Session processing
in the execution of the remaining API First , the client needs to call the Login_with_password function to connect to the XenServer host for authentication, the function creates a session on the server side and returns a reference to the session to the client.
( 3 ) find references to action objects
In order to query the state of an operand or invoke an action on it, the client needs to get a reference to the operand, and there are several ways to get the object reference:
Get_by_name_label: returns a list of all objects of a particular class with a specific label;
Get by UUID: Each class has a UUID , the specified object can be returned by this reference;
Get_all: returns a set of references to all objects of a particular class;
get all records: returns a reference mapping of records for each object of a particular class.
( 4 ) perform synchronous or asynchronous operations with object invocation
Each method call can be synchronous or asynchronous, in addition to the sessions, tasks, and settings of some fields. SyncRPCcall block, which means until the return value is received;RPCCall block return value exactly asRPCreturn value/status code. Only the synchronous calls in this articleAPI, all asynchronous calls are in a special asynchronous namespace. AsynchronousRPCcall to return a taskID, rather than directly returning the result; This identifier is then used to track the running asynchronousRPCthe state. But an asynchronous call can fail immediately, in a taskIDthe task that may be replaced before it is created and then returnedIDis wrapped in aXml-rpcstructure, including error descriptions and field values.
ApiObject Model
This section focuses on the XenServer API types, XenServer API based on the study of the mapping relationship between the main classes and their classes, the API The object model call relationship.
XenServer API The type is simple and there are six data types, as shown in the following table.
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/82/77/wKiom1dWPqvSVnRJAAAx9VxCcRk753.png-wh_500x0-wm_3 -wmp_4-s_3016617194.png "title=" 3.png "alt=" Wkiom1dwpqvsvnrjaaax9vxccrk753.png-wh_50 "/>
XenServer API class, as shown in the following table XenServer all the classes provided , and give a description of each class.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/82/77/wKiom1dWPvSRmt0lAABlF4SrAtc601.png "title=" 3.png " alt= "Wkiom1dwpvsrmt0laablf4sratc601.png"/>
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/82/76/wKioL1dWQAqRIK3kAACESKTfx8Y917.png "title=" 004. PNG "alt=" Wkiol1dwqaqrik3kaacesktfx8y917.png "/>
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/82/76/wKioL1dWQBfDQiwBAAA6uESQUFU058.png "title=" 4.png " alt= "Wkiol1dwqbfdqiwbaaa6uesqufu058.png"/>
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/82/77/wKiom1dWPxvwfTgCAABZ_8CuplM278.png "title=" 4.png " alt= "Wkiom1dwpxvwftgcaabz_8cuplm278.png"/>
XenServer API the relationships between classes are related, and completing a function requires multiple classes of calls to complete, giving a mapping between the main classes:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/82/76/wKioL1dWQDvxhKmjAACQ9waPrSw634.png "title=" 3.png " Width= "642" height= "272" border= "0" hspace= "0" vspace= "0" style= "width:642px;height:272px;" alt= " Wkiol1dwqdvxhkmjaacq9waprsw634.png "/>
in the XenServer XAPI based on the mapping between the type of the class, the primary class, and the class, API the relationship between object models.
( 5 ) API some of the core classes:
VMS : VMS object represents XenServer a specific virtual machine instance on the host or resource pool.
Host: Host object represents an installation in a resource pool XenServer physical host.
VDI : VDI object represents a virtual disk image.
SR : SR ( repository ) Aggregation VDI the collection and encapsulation VDI The property of the physical store where the bit resides.
Network: Network object representation exists in XenServer A second-tier network in the same environment as the host instance.
( 4 vm and the relationship between host, storage, and network:
vbd vbd ( " vdi
VIF : VIF ( Virtual network interface ) object represents VMS and the connection between the network objects.
PIF : PIF ( Physical Interface ) object represents a connection between a host and a network object.
PBD : PBD ( physical block device ) object represents the host and SR ( repository ) the connection between objects.
the creation of a virtual machine is created by Domain 0 to control how virtual machines are stored and how the network is created for the virtual machine's network configuration model:
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/82/77/wKiom1dWP1TjSigBAAAvVcTZbuk805.png "title=" 3.png " alt= "Wkiom1dwp1tjsigbaaavvctzbuk805.png"/>
This article is from "I take fleeting chaos" blog, please be sure to keep this source http://tasnrh.blog.51cto.com/4141731/1786867
The invocation flow of the XAPI of the XenServer architecture