Move main code to virt_df_main.ml and provide explicit interface virt_df.mli
[virt-top.git] / libvirt / libvirt.ml
index 598cd7d..aefc6c4 100644 (file)
@@ -150,7 +150,7 @@ struct
   }
 
   external create_linux : [>`W] Connect.t -> xml -> rw t = "ocaml_libvirt_domain_create_linux"
-  external create_linux_job : [>`W] Connect.t -> xml -> ([`Domain], rw) job_t = "ocaml_libvirt_connect_create_linux_job"
+  external create_linux_job : [>`W] Connect.t -> xml -> ([`Domain], rw) job_t = "ocaml_libvirt_domain_create_linux_job"
   external lookup_by_id : 'a Connect.t -> int -> 'a t = "ocaml_libvirt_domain_lookup_by_id"
   external lookup_by_uuid : 'a Connect.t -> uuid -> 'a t = "ocaml_libvirt_domain_lookup_by_uuid"
   external lookup_by_uuid_string : 'a Connect.t -> string -> 'a t = "ocaml_libvirt_domain_lookup_by_uuid_string"
@@ -228,10 +228,14 @@ end
 module Pool =
 struct
   type 'rw t
-  type pool_state = Inactive | Active
+  type pool_state = Inactive | Building | Running | Degraded
+  type pool_build_flags = New | Repair | Resize
+  type pool_delete_flags = Normal | Zeroed
   type pool_info = {
+    state : pool_state;
     capacity : int64;
     allocation : int64;
+    available : int64;
   }
 
   external lookup_by_name : 'a Connect.t -> string -> 'a t = "ocaml_libvirt_storage_pool_lookup_by_name"
@@ -239,10 +243,11 @@ struct
   external lookup_by_uuid_string : 'a Connect.t -> string -> 'a t = "ocaml_libvirt_storage_pool_lookup_by_uuid_string"
   external create_xml : [>`W] Connect.t -> xml -> rw t = "ocaml_libvirt_storage_pool_create_xml"
   external define_xml : [>`W] Connect.t -> xml -> rw t = "ocaml_libvirt_storage_pool_define_xml"
+  external build : [>`W] t -> pool_build_flags -> unit = "ocaml_libvirt_storage_pool_build"
   external undefine : [>`W] t -> unit = "ocaml_libvirt_storage_pool_undefine"
   external create : [>`W] t -> unit = "ocaml_libvirt_storage_pool_create"
   external destroy : [>`W] t -> unit = "ocaml_libvirt_storage_pool_destroy"
-  external shutdown : [>`W] t -> unit = "ocaml_libvirt_storage_pool_shutdown"
+  external delete : [>`W] t -> unit = "ocaml_libvirt_storage_pool_delete"
   external free : [>`R] t -> unit = "ocaml_libvirt_storage_pool_free"
   external refresh : [`R] t -> unit = "ocaml_libvirt_storage_pool_refresh"
   external get_name : [`R] t -> string = "ocaml_libvirt_storage_pool_get_name"
@@ -252,13 +257,16 @@ struct
   external get_xml_desc : [`R] t -> xml = "ocaml_libvirt_storage_pool_get_xml_desc"
   external get_autostart : [`R] t -> bool = "ocaml_libvirt_storage_pool_get_autostart"
   external set_autostart : [`W] t -> bool -> unit = "ocaml_libvirt_storage_pool_set_autostart"
+  external num_of_volumes : [`R] t -> int = "ocaml_libvirt_storage_pool_num_of_volumes"
+  external list_volumes : [`R] t -> int -> string array = "ocaml_libvirt_storage_pool_list_volumes"
   external const : [>`R] t -> ro t = "%identity"
 end
 
 module Volume =
 struct
   type 'rw t
-  type vol_type = File | Block | Virtual
+  type vol_type = File | Block
+  type vol_delete_flags = Normal | Zeroed
   type vol_info = {
     typ : vol_type;
     capacity : int64;
@@ -266,16 +274,16 @@ struct
   }
 
   external lookup_by_name : 'a Pool.t -> string -> 'a t = "ocaml_libvirt_storage_vol_lookup_by_name"
-  external lookup_by_key : 'a Pool.t -> string -> 'a t = "ocaml_libvirt_storage_vol_lookup_by_key"
-  external lookup_by_path : 'a Pool.t -> string -> 'a t = "ocaml_libvirt_storage_vol_lookup_by_path"
-  external pool_of_volume : 'a t -> 'a Pool.t = "ocaml_libvirt_pool_of_volume"
+  external lookup_by_key : 'a Connect.t -> string -> 'a t = "ocaml_libvirt_storage_vol_lookup_by_key"
+  external lookup_by_path : 'a Connect.t -> string -> 'a t = "ocaml_libvirt_storage_vol_lookup_by_path"
+  external pool_of_volume : 'a t -> 'a Pool.t = "ocaml_libvirt_storage_pool_lookup_by_volume"
   external get_name : [`R] t -> string = "ocaml_libvirt_storage_vol_get_name"
   external get_key : [`R] t -> string = "ocaml_libvirt_storage_vol_get_key"
   external get_path : [`R] t -> string = "ocaml_libvirt_storage_vol_get_path"
   external get_info : [`R] t -> vol_info = "ocaml_libvirt_storage_vol_get_info"
   external get_xml_desc : [`R] t -> xml = "ocaml_libvirt_storage_vol_get_xml_desc"
   external create_xml : [`W] Pool.t -> xml -> unit = "ocaml_libvirt_storage_vol_create_xml"
-  external destroy : [`W] t -> unit = "ocaml_libvirt_storage_vol_destroy"
+  external delete : [`W] t -> unit = "ocaml_libvirt_storage_vol_delete"
   external free : [>`R] t -> unit = "ocaml_libvirt_storage_vol_free"
   external const : [>`R] t -> ro t = "%identity"
 end
@@ -296,6 +304,7 @@ struct
   external get_domain : ([`Domain], 'a) t -> 'a Domain.t = "ocaml_libvirt_job_get_domain"
   external get_network : ([`Network], 'a) t -> 'a Network.t = "ocaml_libvirt_job_get_network"
   external cancel : ('a,'b) t -> unit = "ocaml_libvirt_job_cancel"
+  external free : ('a, [>`R]) t -> unit = "ocaml_libvirt_job_free"
   external const : ('a, [>`R]) t -> ('a, ro) t = "%identity"
 end
 
@@ -347,6 +356,12 @@ struct
     | VIR_ERR_NO_DOMAIN
     | VIR_ERR_NO_NETWORK
     | VIR_ERR_INVALID_MAC
+    | VIR_ERR_AUTH_FAILED
+    | VIR_ERR_INVALID_STORAGE_POOL
+    | VIR_ERR_INVALID_STORAGE_VOL
+    | VIR_WAR_NO_STORAGE
+    | VIR_ERR_NO_STORAGE_POOL
+    | VIR_ERR_NO_STORAGE_VOL
     | VIR_ERR_UNKNOWN of int
 
   let string_of_code = function
@@ -395,6 +410,12 @@ struct
     | VIR_ERR_NO_DOMAIN -> "VIR_ERR_NO_DOMAIN"
     | VIR_ERR_NO_NETWORK -> "VIR_ERR_NO_NETWORK"
     | VIR_ERR_INVALID_MAC -> "VIR_ERR_INVALID_MAC"
+    | VIR_ERR_AUTH_FAILED -> "VIR_ERR_AUTH_FAILED"
+    | VIR_ERR_INVALID_STORAGE_POOL -> "VIR_ERR_INVALID_STORAGE_POOL"
+    | VIR_ERR_INVALID_STORAGE_VOL -> "VIR_ERR_INVALID_STORAGE_VOL"
+    | VIR_WAR_NO_STORAGE -> "VIR_WAR_NO_STORAGE"
+    | VIR_ERR_NO_STORAGE_POOL -> "VIR_ERR_NO_STORAGE_POOL"
+    | VIR_ERR_NO_STORAGE_VOL -> "VIR_ERR_NO_STORAGE_VOL"
     | VIR_ERR_UNKNOWN i -> "VIR_ERR_" ^ string_of_int i
 
   type domain =
@@ -415,6 +436,7 @@ struct
     | VIR_FROM_OPENVZ
     | VIR_FROM_XENXM
     | VIR_FROM_STATS_LINUX
+    | VIR_FROM_STORAGE
     | VIR_FROM_UNKNOWN of int
 
   let string_of_domain = function
@@ -435,6 +457,7 @@ struct
     | VIR_FROM_OPENVZ -> "VIR_FROM_OPENVZ"
     | VIR_FROM_XENXM -> "VIR_FROM_XENXM"
     | VIR_FROM_STATS_LINUX -> "VIR_FROM_STATS_LINUX"
+    | VIR_FROM_STORAGE -> "VIR_FROM_STORAGE"
     | VIR_FROM_UNKNOWN i -> "VIR_FROM_" ^ string_of_int i
 
   type level =