plugin

The xapi toolstack expects all plugins to support a basic query interface.

type debug_info = string

Debug context from the caller

type query_result = struct { ... }

properties of this implementation

Members:

Name Type Description
plugin
string
plugin name, used in the XenAPI as SR.type
name
string
short name
description
string
description
vendor
string
entity (e.g. company, project, group) which produced this implementation
copyright
string
copyright
version
string
version
required_api_version
string
minimum required API version
features
string list
features supported by this plugin
configuration
(string * string) list
key/description pairs describing required device_config parameters
required_cluster_stack
string list
the plugin requires one of these cluster stacks to be active

Plugin

Discover properties of this implementation. Every implementation must support the query interface or it will not be recognised as a storage plugin by xapi.

query

Query this implementation and return its properties. This is called by xapi to determine whether it is compatible with xapi and to discover the supported features.

Definition
OCaml example
Python example
Name Direction Type Description
dbg in debug_info Debug context from the caller
query_result out query_result The properies of this implementation

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
    # ...
        

ls

[ls dbg]: returns a list of attached SRs

Definition
OCaml example
Python example
Name Direction Type Description
dbg in debug_info Debug context from the caller
srs out string list The attached SRs

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.ls ~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 ls x =
        let open Types.Plugin.Ls in
        let open Types in
        return (`Ok (Out.([ "string"; "string" ])))
    (* ... *)
end

Client

        
import xmlrpclib
import xapi
from storage import *

if __name__ == "__main__":
    c = xapi.connect()
    results = c.Plugin.ls({ 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 ls(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["srs"] = [ "string", "string" ]
        return result
    # ...
        

diagnostics

Returns a printable set of backend diagnostic information. Implementations are encouraged to include any data which will be useful to diagnose problems. Note this data should not include personally-identifiable data as it is intended to be automatically included in bug reports.

Definition
OCaml example
Python example
Name Direction Type Description
dbg in debug_info Debug context from the caller
diagnostics out string A string containing loggable human-readable diagnostics information

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.diagnostics ~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 diagnostics x =
        let open Types.Plugin.Diagnostics in
        let open Types in
        return (`Ok (Out.("string")))
    (* ... *)
end

Client

        
import xmlrpclib
import xapi
from storage import *

if __name__ == "__main__":
    c = xapi.connect()
    results = c.Plugin.diagnostics({ 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 diagnostics(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["diagnostics"] = "string"
        return result
    # ...
        

exceptions

Name Type Description
Unimplemented
string
The operation has not been implemented