Client
(* these directives only needed in a toplevel: *)
#require "xcp-api-client";;
#require "lwt";;
#require "lwt.syntax";;
#require "rpc.unix";;
open S
open Plugin
open Types
module Client = Plugin_client(struct
include Lwt
let rpc call = return (Rpc_client.do_rpc ~content_type:`XML ~path:"/" ~host:"127.0.0.1" ~port:80 call) (* TODO: Rpc_client needs to support Lwt *)
end)
let result = Client.query ~dbg:"string";;
Server
(* this line only needed in a toplevel: *)
#require "xcp-api-client";;
open S
open Plugin
module Plugin_myimplementation = functor(M: M) -> struct
(* by default every operation will return a 'not implemented' exception *)
include Plugin_skeleton(M)
(* ... *)
let query x =
let open Types.Plugin.Query in
let open Types in
return (`Ok (Out.({ plugin = "string"; name = "string"; description = "string"; vendor = "string"; copyright = "string"; version = "string"; required_api_version = "string"; features = [ "string"; "string" ]; configuration = [ ("string", "string") ]; required_cluster_stack = [ "string"; "string" ] })))
(* ... *)
end
Client
import xmlrpclib
import xapi
from storage import *
if __name__ == "__main__":
c = xapi.connect()
results = c.Plugin.query({ dbg: "string" })
print (repr(results))
Server
import xmlrpclib
import xapi
from storage import *
class Plugin_myimplementation(Plugin_skeleton):
# by default each method will return a Not_implemented error
# ...
def query(self, dbg):
"""Discover properties of this implementation. Every implementation must support the query interface or it will not be recognised as a storage plugin by xapi."""
result = {}
result["query_result"] = { "plugin": "string", "name": "string", "description": "string", "vendor": "string", "copyright": "string", "version": "string", "required_api_version": "string", "features": [ "string", "string" ], "configuration": { "string": "string" }, "required_cluster_stack": [ "string", "string" ] }
return result
# ...