diff --git a/CommonFunctions.ml b/CommonFunctions.ml new file mode 100644 index 0000000..de6caf9 --- /dev/null +++ b/CommonFunctions.ml @@ -0,0 +1,148 @@ +(* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + *) + +open Printf +open Datamodel_types +module DT = Datamodel_types + +let rec list_distinct list = + match list with + | [] -> [] + | [x] -> [x] + | hd1::(hd2::_ as tl) -> if hd1 = hd2 then list_distinct tl + else hd1::(list_distinct tl) + +let rec list_last = function + | x::[] -> x + | hd::tl -> list_last tl + | [] -> failwith "Cannot return the last element of an empty list." + +and list_index_of x list = + let rec index_rec i = function + | [] -> raise Not_found + | hd::tl -> if hd = x then i else index_rec (i+1) tl + in + try + index_rec 0 list + with Not_found -> -1 + +and list_is_empty list = + match list with + | [] -> true + | _ -> false + +let rec gen_param_groups_for_releases releaseOrder params = + match releaseOrder with + | [] -> [("", [])] + | hd::tl -> (hd, (List.filter (fun x -> List.mem hd x.param_release.internal) params))::(gen_param_groups_for_releases tl params) + +and is_method_static message = + match message.msg_params with + | [] -> true + | {param_name="self"}::_ -> false + | {param_type=ty}::_ -> not (ty = Ref message.msg_obj_name) + +and get_method_params_list message = + if is_method_static message then message.msg_params + else List.tl message.msg_params + +and gen_param_groups message params = + let msgRelease = get_first_release message.msg_release.internal in + let msgReleaseIndex = list_index_of msgRelease DT.release_order in + let paramGroups = gen_param_groups_for_releases DT.release_order params in + let rec getValid x = match x with + | [] -> [] + | hd::tl -> let index = list_index_of (fst hd) DT.release_order in + let valid = if (not (index = -1)) && (not (msgReleaseIndex = -1)) && (index < msgReleaseIndex) then [] + else snd hd in + valid::(getValid tl) + in + let filteredGroups = List.filter (fun x -> match x with | [] -> false | _ -> true) (getValid paramGroups) in + list_distinct filteredGroups + +and get_release_name release = + if release = rel_rio then "XenServer 4.0" + else if release = rel_miami then "XenServer 4.1" + else if release = rel_symc then "XenServer 4.1.1" + else if release = rel_orlando then "XenServer 5.0" + else if release = rel_orlando_update_1 then "XenServer 5.0 Update 1" + else if release = rel_george then "XenServer 5.5" + else if release = rel_midnight_ride then "XenServer 5.6" + else if release = rel_cowley then "XenServer 5.6 FP1" + else if release = rel_boston then "XenServer 6.0" + else if release = rel_tampa then "XenServer 6.1" + else if release = rel_clearwater then "XenServer 6.2" + else if release = rel_vgpu_tech_preview then "XenServer 6.2 SP1 Tech-Preview" + else if release = rel_vgpu_productisation then "XenServer 6.2 SP1" + else if release = rel_augusta then "Unreleased" + else "" + +and get_first_release releases = + let filtered = List.filter (fun x -> List.mem x releases) DT.release_order in + match filtered with + | [] -> "" + | hd::tl -> hd + +and get_first_release_string release = + if release = "" then "" + else sprintf "First published in %s." (get_release_name release) + +and get_published_info_message message cls = + let clsRelease = get_first_release cls.obj_release.internal in + let msgRelease = get_first_release message.msg_release.internal in + let clsReleaseIndex = list_index_of clsRelease DT.release_order in + let msgReleaseIndex = list_index_of msgRelease DT.release_order in + if (not (clsReleaseIndex = -1)) && (not (msgReleaseIndex = -1)) && (clsReleaseIndex < msgReleaseIndex) then + get_first_release_string msgRelease + else + get_first_release_string clsRelease + +and get_published_info_param message param = + let msgRelease = get_first_release message.msg_release.internal in + let paramRelease = get_first_release param.param_release.internal in + let msgReleaseIndex = list_index_of msgRelease DT.release_order in + let paramReleaseIndex = list_index_of paramRelease DT.release_order in + if (not (msgReleaseIndex = -1)) && (not (paramReleaseIndex = -1)) && (msgReleaseIndex < paramReleaseIndex) then + get_first_release_string paramRelease + else "" + +and get_published_info_class cls = + get_first_release_string (get_first_release cls.obj_release.internal) + +and get_published_info_field field cls = + let clsRelease = get_first_release cls.obj_release.internal in + let fieldRelease = get_first_release field.release.internal in + let clsReleaseIndex = list_index_of clsRelease DT.release_order in + let fieldReleaseIndex = list_index_of fieldRelease DT.release_order in + if (not (clsReleaseIndex = -1)) && (not (fieldReleaseIndex = -1)) && (clsReleaseIndex < fieldReleaseIndex) then + get_first_release_string fieldRelease + else + "" + diff --git a/OMakefile b/OMakefile index 71a776f..30298bc 100644 --- a/OMakefile +++ b/OMakefile @@ -42,7 +42,7 @@ CSHARP_SAM_TMP=$(BINDINGS_TMP)/XenServer.NET-sam/XenServer.NET OCAMLINCLUDES += .. $(DATAMODEL_DIR) OCAMLFLAGS += -dtypes -I $(DATAMODEL_DIR) -thread -OCAMLPACKS += rpclib getopt xmlm xml-light2 uuid stdext xcp unix +OCAMLPACKS += rpclib getopt xmlm xml-light2 uuid stdext xcp unix str OCAML_LIBS += $(DATAMODEL_DIR)/datamodel .PHONY: clean dist @@ -107,7 +107,7 @@ $(BINDINGS_TMP)/XenCenterBindings.zip: gen_gui_csharp_bindings Flip($(CSHARP_GUI_TMP)) ZipUp($(CSHARP_GUI_TMP), $@) -powershell_src: csharp_src gen_powershell_bindings powershell_samples +powershell_src: csharp_src gen_powershell_bindings mkdir -p $(POWERSHELL_TMP) $(INSTALL) powershell/src/*.cs $(POWERSHELL_TMP) sed -i -e 's/1\.0\.0\.0/$(PRODUCT_VERSION)/g' $(POWERSHELL_TMP)/AssemblyInfo.cs diff --git a/c/OMakefile b/c/OMakefile index 94fb1b9..569c91c 100644 --- a/c/OMakefile +++ b/c/OMakefile @@ -38,8 +38,6 @@ SDK_C_FOLDER=$(SDK_FOLDER)/libxenserver C_BIN_FOLDER=$(SDK_C_FOLDER)/bin/ C_SRC_FOLDER=$(SDK_C_FOLDER)/src/ -OCAMLFLAGS += -dtypes -thread -OCAMLPACKS += getopt str xmlm xml-light2 uuid CFLAGS += $(shell xml2-config --cflags) $(shell curl-config --cflags) -W -Wall -Wmissing-prototypes -Werror -std=c99 -g -O2 COMPAT_PATCH = compat.patch @@ -52,12 +50,11 @@ else export section - OCamlProgram(gen_c_binding$(EXE), gen_c_binding helper ../licence) + OCamlProgram(gen_c_binding, gen_c_binding helper ../licence) -COMMON = xen_common.c xen_common.h xen_string_set.c xen_string_set.h xen_internal.h .PHONY: c_source -c_source: $(COMMON) gen_c_binding$(EXE) +c_source: gen_c_binding rm -Rf $(C_SRC_TMP_FOLDER) mkdir -p $(C_SRC_TMP_FOLDER)/include mkdir -p $(C_SRC_TMP_FOLDER)/src @@ -65,7 +62,7 @@ c_source: $(COMMON) gen_c_binding$(EXE) if $(equal $(COMPILE_C), yes) rm -Rf $(C_GEN_FOLDER) mkdir -p $(C_GEN_FOLDER) - ./gen_c_binding$(EXE) -d $(C_GEN_FOLDER) + ./gen_c_binding -d $(C_GEN_FOLDER) (cd $(C_GEN_FOLDER) && patch -p0 <$(COMPAT_PATCH)) cp -r $(C_GEN_FOLDER)/xen $(C_SRC_TMP_FOLDER)/include cp $(C_GEN_FOLDER)/*.h $(C_SRC_TMP_FOLDER)/include @@ -97,4 +94,4 @@ c_folders: c_binaries c_source .PHONY: clean clean: rm -f *.annot *.o *.cmi *.cmx *.cmo *.cma *.cmxa *.run *.omc - rm -f gen_c_binding$(EXE) + rm -f gen_c_binding diff --git a/csharp/OMakefile b/csharp/OMakefile index b98b323..cdfe574 100644 --- a/csharp/OMakefile +++ b/csharp/OMakefile @@ -28,19 +28,19 @@ # OF THE POSSIBILITY OF SUCH DAMAGE. # -.DEFAULT: gen_csharp_binding - SR_XML = $(PROJECT_OUTPUTDIR)/sm/XE_SR_ERRORCODES.xml -OCamlProgram(gen_csharp_binding$(EXE), gen_csharp_binding ../friendly_error_names ../licence) +OCamlProgram(gen_csharp_binding, gen_csharp_binding ../friendly_error_names ../licence ../CommonFunctions) .PHONY: gen_gui_csharp_bindings -gen_gui_csharp_bindings: gen_csharp_binding$(EXE) $(SR_XML) +gen_gui_csharp_bindings: gen_csharp_binding $(SR_XML) rm -Rf $(CSHARP_GEN) mkdir -p $(CSHARP_GEN) - ./gen_csharp_binding$(EXE) -s $(SR_XML) -d $(CSHARP_GEN) + ./gen_csharp_binding -s $(SR_XML) -d $(CSHARP_GEN) .PHONY: clean clean: rm -f *.annot *.o *.cmi *.cmx *.cmo *.cma *.cmxa *.run *.omc - rm -f gen_csharp_binding$(EXE) + rm -f gen_csharp_binding + +.DEFAULT: gen_csharp_binding diff --git a/csharp/gen_csharp_binding.ml b/csharp/gen_csharp_binding.ml index 382650e..384ed6c 100644 --- a/csharp/gen_csharp_binding.ml +++ b/csharp/gen_csharp_binding.ml @@ -38,6 +38,8 @@ open Datamodel open Datamodel_types open Dm_api +open CommonFunctions + module DT = Datamodel_types module DU = Datamodel_utils @@ -139,7 +141,7 @@ let rec main() = gen_proxy(); gen_callversionscsv(); List.iter (fun x -> if generated x then gen_class x) classes; - gen_gui_bits classes; + gen_object_downloader classes; TypeSet.iter gen_enum !enums; gen_maps(); gen_i18n_errors(); @@ -309,20 +311,19 @@ namespace XenAPI (* ------------------- category: classes *) -and gen_class {name=classname; messages=messages; contents=contents; - gen_constructor_destructor=gen_constructor_destructor } = - let out_chan = open_out (Filename.concat destdir - ((exposed_class_name classname) ^ ".cs")) +and gen_class cls = + let out_chan = open_out (Filename.concat destdir (exposed_class_name cls.name)^".cs") in - finally (fun () -> gen_class_gui out_chan classname messages contents - gen_constructor_destructor) + finally (fun () -> gen_class_gui out_chan cls) (fun () -> close_out out_chan) (* XenAPI autogen class generator for GUI bindings *) -and gen_class_gui out_chan classname messages contents gen_constructor_destructor = +and gen_class_gui out_chan cls = let print format = fprintf out_chan format in - let exposed_class_name = exposed_class_name classname in - let messages = List.filter (fun msg -> (String.compare msg.msg_name "get_all_records_where" != 0)) messages in + let exposed_class_name = exposed_class_name cls.name in + let messages = List.filter (fun msg -> (String.compare msg.msg_name "get_all_records_where" != 0)) cls.messages in + let contents = cls.contents in + let publishedInfo = get_published_info_class cls in print "%s @@ -336,14 +337,18 @@ using CookComputing.XmlRpc; namespace XenAPI { + /// + /// %s%s + /// public partial class %s : XenObject<%s> {" (banner()) + cls.description (if publishedInfo = "" then "" else "\n /// "^publishedInfo) exposed_class_name exposed_class_name; (* Generate bits for Message type *) - if classname = "message" then + if cls.name = "message" then begin print " public enum MessageType { %s }; @@ -379,8 +384,8 @@ namespace XenAPI exposed_class_name; let print_internal_ctor = function - [] -> () - | _ as contents -> print + | [] -> () + | _ as cnt -> print " public %s(%s) { @@ -388,8 +393,8 @@ namespace XenAPI } " exposed_class_name - (String.concat ",\n " (List.rev (get_constructor_params contents))) - (String.concat "\n " (List.rev (get_constructor_body contents))) + (String.concat ",\n " (List.rev (get_constructor_params cnt))) + (String.concat "\n " (List.rev (get_constructor_body cnt))) in print_internal_ctor contents; print @@ -497,7 +502,7 @@ namespace XenAPI " exposed_class_name; - if gen_constructor_destructor then + if cls.gen_constructor_destructor then print " Proxy_%s p = this.ToProxy(); return session.proxy.%s_create(session.uuid, p).parse(); @@ -520,21 +525,18 @@ namespace XenAPI print " } - } - -"; - - List.iter (gen_exposed_method out_chan classname) (List.filter (fun x -> not x.msg_hide_from_docs) messages); + }"; + + List.iter (gen_exposed_method_overloads out_chan cls) (List.filter (fun x -> not x.msg_hide_from_docs) messages); (* Don't create duplicate get_all_records call *) - if (not (List.exists (fun msg -> String.compare msg.msg_name "get_all_records" = 0) messages)) then - gen_exposed_method out_chan classname (get_all_records_method classname); + if not (List.exists (fun msg -> String.compare msg.msg_name "get_all_records" = 0) messages) then + gen_exposed_method out_chan cls (get_all_records_method cls.name) []; - List.iter (gen_exposed_field out_chan classname) contents; + List.iter (gen_exposed_field out_chan cls) contents; -print -" - } + print +" } } "; @@ -628,55 +630,84 @@ and gen_to_proxy_line out_chan content = | Namespace (_, c) -> List.iter (gen_to_proxy_line out_chan) c +and gen_overload out_chan classname message generator = + let methodParams = get_method_params_list message in + match methodParams with + | [] -> generator [] + | _ -> let paramGroups = gen_param_groups message methodParams in + List.iter generator paramGroups +and gen_exposed_method_overloads out_chan cls message = + let generator = fun x -> gen_exposed_method out_chan cls message x in + gen_overload out_chan cls.name message generator -and gen_exposed_method out_chan classname msg = +and gen_exposed_method out_chan cls msg curParams = + let classname = cls.name in let print format = fprintf out_chan format in - - let proxy_msg_name = proxy_msg_name classname msg in + let proxyMsgName = proxy_msg_name classname msg in let exposed_ret_type = exposed_type_opt msg.msg_result in - let params = exposed_params msg.msg_params in - let call_params = exposed_call_params msg.msg_params in - let do_call = - sprintf "session.proxy.%s(%s).parse()" proxy_msg_name call_params in - let do_async_call = - sprintf "session.proxy.async_%s(%s).parse()" proxy_msg_name call_params in - let conv = convert_from_proxy_opt do_call msg.msg_result in - let async_conv = sprintf "return XenRef.Create(%s)" do_async_call in - - print -" public static %s %s(%s) + let paramSignature = exposed_params msg classname curParams in + let paramsDoc = get_params_doc msg classname curParams in + let callParams = exposed_call_params msg classname curParams in + let publishInfo = get_published_info_message msg cls in + print " + /// + /// %s%s + /// %s + public static %s %s(%s) { %s; - } - -" exposed_ret_type msg.msg_name params conv; - + }\n" + msg.msg_doc (if publishInfo = "" then "" else "\n /// "^publishInfo) + paramsDoc + exposed_ret_type msg.msg_name paramSignature + (convert_from_proxy_opt (sprintf "session.proxy.%s(%s).parse()" proxyMsgName callParams) msg.msg_result); if msg.msg_async then - print -" public static XenRef async_%s(%s) + print " + /// + /// %s%s + /// %s + public static XenRef async_%s(%s) { - %s; - } - -" msg.msg_name params async_conv + return XenRef.Create(session.proxy.async_%s(%s).parse()); + }\n" + msg.msg_doc (if publishInfo = "" then "" else "\n /// "^publishInfo) + paramsDoc + msg.msg_name paramSignature + proxyMsgName callParams and returns_xenobject msg = match msg.msg_result with | Some (Record r, _) -> true | _ -> false -and exposed_params params = - String.concat ", " ("Session session" :: (List.map exposed_param params)) +and get_params_doc msg classname params = + let sessionDoc = "\n /// The session" in + let refDoc = if is_method_static msg then "" + else sprintf "\n /// The opaque_ref of the given %s" + (String.lowercase classname) (String.capitalize classname) in + String.concat "" (sessionDoc::(refDoc::(List.map (fun x -> get_param_doc msg x) params))) +and get_param_doc msg x = + let publishInfo = get_published_info_param msg x in + sprintf "\n /// %s%s" (String.lowercase x.param_name) x.param_doc + (if publishInfo = "" then "" else " "^publishInfo) + +and exposed_params message classname params = + let exposedParams = List.map exposed_param params in + let refParam = sprintf "string _%s" (String.lowercase classname) in + let exposedParams = if is_method_static message then exposedParams else refParam::exposedParams in + String.concat ", " ("Session session"::exposedParams) and exposed_param p = sprintf "%s _%s" (internal_type p.param_type) (String.lowercase p.param_name) - -and exposed_call_params params = - String.concat ", " ("session.uuid" :: (List.map exposed_call_param params)) - +and exposed_call_params message classname params = + let exposedParams = List.map exposed_call_param params in + let name = String.lowercase classname in + let refParam = sprintf "(_%s != null) ? _%s : \"\"" name name in + let exposedParams = if is_method_static message then exposedParams else refParam::exposedParams in + String.concat ", " ("session.uuid"::exposedParams) and exposed_call_param p = convert_to_proxy (sprintf "_%s" (String.lowercase p.param_name)) p.param_type @@ -730,34 +761,45 @@ and ctor_call classname = String.concat ", " ("session.uuid" :: args) -and gen_exposed_field out_chan classname content = +and gen_exposed_field out_chan cls content = match content with | Field fr -> let print format = fprintf out_chan format in let full_name_fr = full_name fr in let comp = sprintf "!Helper.AreEqual(value, _%s)" full_name_fr in + let publishInfo = get_published_info_field fr cls in + + print " + /// + /// %s%s + /// + public virtual %s %s + { + get { return _%s; }" fr.field_description + (if publishInfo = "" then "" else "\n /// "^publishInfo) + (exposed_type fr.ty) full_name_fr full_name_fr; print -" private %s _%s; -" (exposed_type fr.ty) full_name_fr; - - print -" public virtual %s %s { - get { return _%s; } -" (exposed_type fr.ty) full_name_fr - full_name_fr; - - print -" set { if (%s) { _%s = value; Changed = true; NotifyPropertyChanged(\"%s\"); } } -" comp full_name_fr full_name_fr; +" + set + { + if (%s) + { + _%s = value; + Changed = true; + NotifyPropertyChanged(\"%s\"); + } + } + }" comp full_name_fr full_name_fr; - print " }\n\n" + print " + private %s _%s;\n" (exposed_type fr.ty) full_name_fr - | Namespace (_, c) -> List.iter (gen_exposed_field out_chan classname) c + | Namespace (_, c) -> List.iter (gen_exposed_field out_chan cls) c (* ------------------- category: gui bits *) -and gen_gui_bits classes = +and gen_object_downloader classes = let out_chan = open_out (Filename.concat destdir "XenObjectDownloader.cs") in finally (fun () -> gen_xenobjectdownloader out_chan classes) @@ -1217,10 +1259,6 @@ namespace XenAPI { public partial interface Proxy : IXmlRpcProxy { - [XmlRpcMethod(\"session.login_with_password\")] - Response session_login_with_password(string username, - string password); - [XmlRpcMethod(\"event.get_record\")] Response event_get_record(string session, string _event); @@ -1270,9 +1308,9 @@ namespace XenAPI and gen_proxy_for_class out_chan {name=classname; messages=messages} = (* Generate each of the proxy methods (but not the internal-only ones that are marked hide_from_docs) *) - List.iter (gen_proxy_method out_chan classname) (List.filter (fun x -> not x.msg_hide_from_docs) messages); + List.iter (gen_proxy_method_overloads out_chan classname) (List.filter (fun x -> not x.msg_hide_from_docs) messages); if (not (List.exists (fun msg -> String.compare msg.msg_name "get_all_records" = 0) messages)) then - gen_proxy_method out_chan classname (get_all_records_method classname) + gen_proxy_method out_chan classname (get_all_records_method classname) [] (*Generate a csv file detailing the call name and when it was added - used for testing*) and gen_callversionscsv() = @@ -1299,46 +1337,40 @@ and gen_callversionscsv_method out_chan classname message = in List.iter (fun (t, rel, doc) -> printRel rel) published -and gen_proxy_method out_chan classname message = +and gen_proxy_method_overloads out_chan classname message = + let generator = fun x -> gen_proxy_method out_chan classname message x in + gen_overload out_chan classname message generator + +and gen_proxy_method out_chan classname message params = let print format = fprintf out_chan format in let proxy_ret_type = proxy_type_opt message.msg_result in let proxy_msg_name = proxy_msg_name classname message in - let proxy_params = proxy_params message.msg_session message.msg_params in + let proxyParams = proxy_params message classname params in - print -" + print " [XmlRpcMethod(\"%s.%s\")] Response<%s> %s(%s); - " classname message.msg_name proxy_ret_type - proxy_msg_name proxy_params; + proxy_msg_name proxyParams; if message.msg_async then - print -" + print " [XmlRpcMethod(\"Async.%s.%s\")] Response async_%s(%s); - " classname message.msg_name - proxy_msg_name proxy_params; + proxy_msg_name proxyParams; -and proxy_params session params = +and proxy_params message classname params = + let refParam = sprintf "string _%s" (String.lowercase classname) in let args = List.map proxy_param params in - let args = List.filter not_empty args in - let args = if session then "string session" :: args else args in + let args = if is_method_static message then args else refParam::args in + let args = if message.msg_session then "string session" :: args else args in String.concat ", " args - -and not_empty s = - match s with - "" -> false - | _ -> true - - and proxy_param p = sprintf "%s _%s" (proxy_type p.param_type) (String.lowercase p.param_name) @@ -1438,13 +1470,8 @@ and gen_enum_line content = and has_unknown_entry contents = let rec f = function - | x :: xs -> - if String.lowercase (fst x) = "unknown" then - true - else - f xs - | [] -> - false + | x :: xs -> if String.lowercase (fst x) = "unknown" then true else f xs + | [] -> false in f contents @@ -1867,7 +1894,6 @@ and i18n_footer out_chan = let print format = fprintf out_chan format in print "\n" - and gen_i18n_errors () = Friendly_error_names.parse_sr_xml sr_xml; Friendly_error_names.parse_resx "../FriendlyErrorNames.resx"; diff --git a/csharp/src/Overloads.cs b/csharp/src/Overloads.cs deleted file mode 100644 index 07f3f26..0000000 --- a/csharp/src/Overloads.cs +++ /dev/null @@ -1,407 +0,0 @@ -/* - * Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using System.Collections.Generic; - -using CookComputing.XmlRpc; - - -namespace XenAPI -{ - public partial interface Proxy : IXmlRpcProxy - { - #region pre-6.2 compatibility - - [XmlRpcMethod("session.login_with_password")] - Response - session_login_with_password(string _uname, string _pwd, string _version); - - [XmlRpcMethod("host.apply_edition")] - Response - host_apply_edition(string session, string _host, string _edition); - - #endregion - - #region pre-6.1 compatibility - - [XmlRpcMethod("Bond.create")] - Response - bond_create(string session, string _network, string[] _members, string _mac, string _mode); - - [XmlRpcMethod("Async.Bond.create")] - Response - async_bond_create(string session, string _network, string[] _members, string _mac, string _mode); - - [XmlRpcMethod("pool.create_new_blob")] - Response - pool_create_new_blob(string session, string _pool, string _name, string _mime_type); - - [XmlRpcMethod("Async.pool.create_new_blob")] - Response - async_pool_create_new_blob(string session, string _pool, string _name, string _mime_type); - - [XmlRpcMethod("VM.create_new_blob")] - Response - vm_create_new_blob(string session, string _vm, string _name, string _mime_type); - - [XmlRpcMethod("Async.VM.create_new_blob")] - Response - async_vm_create_new_blob(string session, string _vm, string _name, string _mime_type); - - [XmlRpcMethod("host.create_new_blob")] - Response - host_create_new_blob(string session, string _host, string _name, string _mime_type); - - [XmlRpcMethod("Async.host.create_new_blob")] - Response - async_host_create_new_blob(string session, string _host, string _name, string _mime_type); - - [XmlRpcMethod("network.create_new_blob")] - Response - network_create_new_blob(string session, string _network, string _name, string _mime_type); - - [XmlRpcMethod("Async.network.create_new_blob")] - Response - async_network_create_new_blob(string session, string _network, string _name, string _mime_type); - - [XmlRpcMethod("PIF.db_introduce")] - Response - pif_db_introduce(string session, string _device, string _network, string _host, string _mac, string _mtu, string _vlan, bool _physical, string _ip_configuration_mode, string _ip, string _netmask, string _gateway, string _dns, string _bond_slave_of, string _vlan_master_of, bool _management, Object _other_config, bool _disallow_unplug); - - [XmlRpcMethod("Async.PIF.db_introduce")] - Response - async_pif_db_introduce(string session, string _device, string _network, string _host, string _mac, string _mtu, string _vlan, bool _physical, string _ip_configuration_mode, string _ip, string _netmask, string _gateway, string _dns, string _bond_slave_of, string _vlan_master_of, bool _management, Object _other_config, bool _disallow_unplug); - - [XmlRpcMethod("SR.create_new_blob")] - Response - sr_create_new_blob(string session, string _sr, string _name, string _mime_type); - - [XmlRpcMethod("Async.SR.create_new_blob")] - Response - async_sr_create_new_blob(string session, string _sr, string _name, string _mime_type); - - [XmlRpcMethod("VDI.introduce")] - Response - vdi_introduce(string session, string _uuid, string _name_label, string _name_description, string _sr, string _type, bool _sharable, bool _read_only, Object _other_config, string _location, Object _xenstore_data, Object _sm_config); - - [XmlRpcMethod("Async.VDI.introduce")] - Response - async_vdi_introduce(string session, string _uuid, string _name_label, string _name_description, string _sr, string _type, bool _sharable, bool _read_only, Object _other_config, string _location, Object _xenstore_data, Object _sm_config); - - [XmlRpcMethod("VDI.db_introduce")] - Response - vdi_db_introduce(string session, string _uuid, string _name_label, string _name_description, string _sr, string _type, bool _sharable, bool _read_only, Object _other_config, string _location, Object _xenstore_data, Object _sm_config); - - [XmlRpcMethod("Async.VDI.db_introduce")] - Response - async_vdi_db_introduce(string session, string _uuid, string _name_label, string _name_description, string _sr, string _type, bool _sharable, bool _read_only, Object _other_config, string _location, Object _xenstore_data, Object _sm_config); - - [XmlRpcMethod("blob.create")] - Response - blob_create(string session, string _mime_type); - - #endregion - - #region pre-6.0 compatibility - - [XmlRpcMethod("Bond.create")] - Response - bond_create(string session, string _network, string[] _members, string _mac); - - [XmlRpcMethod("Async.Bond.create")] - Response - async_bond_create(string session, string _network, string[] _members, string _mac); - - #endregion - } - - public partial class Blob - { - /// - /// Backward compatibility for Blob.create in XenServer 6.0. - /// - public static XenRef create(Session session, string _mime_type) - { - if (Helper.APIVersionMeets(session, API_Version.API_1_10)) - System.Diagnostics.Debug.Assert(false, "Cannot use this call on XenServer 6.1 or newer."); - - return XenRef.Create(session.proxy.blob_create(session.uuid, (_mime_type != null) ? _mime_type : "").parse()); - } - } - - public partial class Bond - { - // Backward compatibility for Bond.create in XenServer 5.x. - - public static XenRef create(Session session, string _network, List> _members, string _mac) - { - if (Helper.APIVersionMeets(session, API_Version.API_1_9)) - System.Diagnostics.Debug.Assert(false, "Cannot use this call on XenServer 6.0 or newer."); - - return XenRef.Create(session.proxy.bond_create(session.uuid, (_network != null) ? _network : "", (_members != null) ? Helper.RefListToStringArray(_members) : new string[] { }, (_mac != null) ? _mac : "").parse()); - } - - public static XenRef async_create(Session session, string _network, List> _members, string _mac) - { - if (Helper.APIVersionMeets(session, API_Version.API_1_9)) - System.Diagnostics.Debug.Assert(false, "Cannot use this call on XenServer 6.0 or newer."); - - return XenRef.Create(session.proxy.async_bond_create(session.uuid, (_network != null) ? _network : "", (_members != null) ? Helper.RefListToStringArray(_members) : new string[] { }, (_mac != null) ? _mac : "").parse()); - } - - // Backward compatibility for Bond.create in XenServer 6.0. - - public static XenRef create(Session session, string _network, List> _members, string _mac, bond_mode _mode) - { - if (Helper.APIVersionMeets(session, API_Version.API_1_10)) - System.Diagnostics.Debug.Assert(false, "Cannot use this call on XenServer 6.1 or newer."); - - return XenRef.Create(session.proxy.bond_create(session.uuid, (_network != null) ? _network : "", (_members != null) ? Helper.RefListToStringArray(_members) : new string[] { }, (_mac != null) ? _mac : "", bond_mode_helper.ToString(_mode)).parse()); - } - - public static XenRef async_create(Session session, string _network, List> _members, string _mac, bond_mode _mode) - { - if (Helper.APIVersionMeets(session, API_Version.API_1_10)) - System.Diagnostics.Debug.Assert(false, "Cannot use this call on XenServer 6.1 or newer."); - - return XenRef.Create(session.proxy.async_bond_create(session.uuid, (_network != null) ? _network : "", (_members != null) ? Helper.RefListToStringArray(_members) : new string[] { }, (_mac != null) ? _mac : "", bond_mode_helper.ToString(_mode)).parse()); - } - } - - public partial class Host - { - /// - /// Backward compatibility for Host.create_new_blob in XenServer 6.0. - /// - public static XenRef create_new_blob(Session session, string _host, string _name, string _mime_type) - { - if (Helper.APIVersionMeets(session, API_Version.API_1_10)) - System.Diagnostics.Debug.Assert(false, "Cannot use this call on XenServer 6.1 or newer."); - - return XenRef.Create(session.proxy.host_create_new_blob(session.uuid, (_host != null) ? _host : "", (_name != null) ? _name : "", (_mime_type != null) ? _mime_type : "").parse()); - } - - /// - /// Backward compatibility for Host.async_create_new_blob in XenServer 6.0. - /// - public static XenRef async_create_new_blob(Session session, string _host, string _name, string _mime_type) - { - if (Helper.APIVersionMeets(session, API_Version.API_1_10)) - System.Diagnostics.Debug.Assert(false, "Cannot use this call on XenServer 6.1 or newer."); - - return XenRef.Create(session.proxy.async_host_create_new_blob(session.uuid, (_host != null) ? _host : "", (_name != null) ? _name : "", (_mime_type != null) ? _mime_type : "").parse()); - } - - /// - /// Backward compatibility for Host.apply_edition in XenServer 6.1. - /// - public static void apply_edition(Session session, string _host, string _edition) - { - if (Helper.APIVersionMeets(session, API_Version.API_2_0)) - System.Diagnostics.Debug.Assert(false, "Cannot use this call on XenServer 6.2 or newer."); - - session.proxy.host_apply_edition(session.uuid, (_host != null) ? _host : "", (_edition != null) ? _edition : "").parse(); - } - } - - public partial class Network - { - /// - /// Backward compatibility for Network.create_new_blob in XenServer 6.0. - /// - public static XenRef create_new_blob(Session session, string _network, string _name, string _mime_type) - { - if (Helper.APIVersionMeets(session, API_Version.API_1_10)) - System.Diagnostics.Debug.Assert(false, "Cannot use this call on XenServer 6.1 or newer."); - - return XenRef.Create(session.proxy.network_create_new_blob(session.uuid, (_network != null) ? _network : "", (_name != null) ? _name : "", (_mime_type != null) ? _mime_type : "").parse()); - } - - /// - /// Backward compatibility for Network.async_create_new_blob in XenServer 6.0. - /// - public static XenRef async_create_new_blob(Session session, string _network, string _name, string _mime_type) - { - if (Helper.APIVersionMeets(session, API_Version.API_1_10)) - System.Diagnostics.Debug.Assert(false, "Cannot use this call on XenServer 6.1 or newer."); - - return XenRef.Create(session.proxy.async_network_create_new_blob(session.uuid, (_network != null) ? _network : "", (_name != null) ? _name : "", (_mime_type != null) ? _mime_type : "").parse()); - } - } - - public partial class PIF - { - /// - /// Backward compatibility for PIF.db_introduce in XenServer 6.0. - /// - public static XenRef db_introduce(Session session, string _device, string _network, string _host, string _mac, long _mtu, long _vlan, bool _physical, ip_configuration_mode _ip_configuration_mode, string _ip, string _netmask, string _gateway, string _dns, string _bond_slave_of, string _vlan_master_of, bool _management, Dictionary _other_config, bool _disallow_unplug) - { - if (Helper.APIVersionMeets(session, API_Version.API_1_10)) - System.Diagnostics.Debug.Assert(false, "Cannot use this call on XenServer 6.1 or newer."); - - return XenRef.Create(session.proxy.pif_db_introduce(session.uuid, (_device != null) ? _device : "", (_network != null) ? _network : "", (_host != null) ? _host : "", (_mac != null) ? _mac : "", _mtu.ToString(), _vlan.ToString(), _physical, ip_configuration_mode_helper.ToString(_ip_configuration_mode), (_ip != null) ? _ip : "", (_netmask != null) ? _netmask : "", (_gateway != null) ? _gateway : "", (_dns != null) ? _dns : "", (_bond_slave_of != null) ? _bond_slave_of : "", (_vlan_master_of != null) ? _vlan_master_of : "", _management, Maps.convert_to_proxy_string_string(_other_config), _disallow_unplug).parse()); - } - - /// - /// Backward compatibility for PIF.async_db_introduce in XenServer 6.0. - /// - public static XenRef async_db_introduce(Session session, string _device, string _network, string _host, string _mac, long _mtu, long _vlan, bool _physical, ip_configuration_mode _ip_configuration_mode, string _ip, string _netmask, string _gateway, string _dns, string _bond_slave_of, string _vlan_master_of, bool _management, Dictionary _other_config, bool _disallow_unplug) - { - if (Helper.APIVersionMeets(session, API_Version.API_1_10)) - System.Diagnostics.Debug.Assert(false, "Cannot use this call on XenServer 6.1 or newer."); - - return XenRef.Create(session.proxy.async_pif_db_introduce(session.uuid, (_device != null) ? _device : "", (_network != null) ? _network : "", (_host != null) ? _host : "", (_mac != null) ? _mac : "", _mtu.ToString(), _vlan.ToString(), _physical, ip_configuration_mode_helper.ToString(_ip_configuration_mode), (_ip != null) ? _ip : "", (_netmask != null) ? _netmask : "", (_gateway != null) ? _gateway : "", (_dns != null) ? _dns : "", (_bond_slave_of != null) ? _bond_slave_of : "", (_vlan_master_of != null) ? _vlan_master_of : "", _management, Maps.convert_to_proxy_string_string(_other_config), _disallow_unplug).parse()); - } - } - - public partial class Pool : XenObject - { - /// - /// Backward compatibility for Pool.create_new_blob in XenServer 6.0. - /// - public static XenRef create_new_blob(Session session, string _pool, string _name, string _mime_type) - { - if (Helper.APIVersionMeets(session, API_Version.API_1_10)) - System.Diagnostics.Debug.Assert(false, "Cannot use this call on XenServer 6.1 or newer."); - - return XenRef.Create(session.proxy.pool_create_new_blob(session.uuid, (_pool != null) ? _pool : "", (_name != null) ? _name : "", (_mime_type != null) ? _mime_type : "").parse()); - } - - /// - /// Backward compatibility for Pool.async_create_new_blob in XenServer 6.0. - /// - public static XenRef async_create_new_blob(Session session, string _pool, string _name, string _mime_type) - { - if (Helper.APIVersionMeets(session, API_Version.API_1_10)) - System.Diagnostics.Debug.Assert(false, "Cannot use this call on XenServer 6.1 or newer."); - - return XenRef.Create(session.proxy.async_pool_create_new_blob(session.uuid, (_pool != null) ? _pool : "", (_name != null) ? _name : "", (_mime_type != null) ? _mime_type : "").parse()); - } - } - - public partial class SR - { - /// - /// Backward compatibility for SR.create_new_blob in XenServer 6.0. - /// - public static XenRef create_new_blob(Session session, string _sr, string _name, string _mime_type) - { - if (Helper.APIVersionMeets(session, API_Version.API_1_10)) - System.Diagnostics.Debug.Assert(false, "Cannot use this call on XenServer 6.1 or newer."); - - return XenRef.Create(session.proxy.sr_create_new_blob(session.uuid, (_sr != null) ? _sr : "", (_name != null) ? _name : "", (_mime_type != null) ? _mime_type : "").parse()); - } - - /// - /// Backward compatibility for SR.async_create_new_blob in XenServer 6.0. - /// - public static XenRef async_create_new_blob(Session session, string _sr, string _name, string _mime_type) - { - if (Helper.APIVersionMeets(session, API_Version.API_1_10)) - System.Diagnostics.Debug.Assert(false, "Cannot use this call on XenServer 6.1 or newer."); - - return XenRef.Create(session.proxy.async_sr_create_new_blob(session.uuid, (_sr != null) ? _sr : "", (_name != null) ? _name : "", (_mime_type != null) ? _mime_type : "").parse()); - } - } - - public partial class VDI - { - /// - /// Backward compatibility for VDI.introduce in XenServer 6.0. - /// - public static XenRef introduce(Session session, string _uuid, string _name_label, string _name_description, string _sr, vdi_type _type, bool _sharable, bool _read_only, Dictionary _other_config, string _location, Dictionary _xenstore_data, Dictionary _sm_config) - { - if (Helper.APIVersionMeets(session, API_Version.API_1_10)) - System.Diagnostics.Debug.Assert(false, "Cannot use this call on XenServer 6.1 or newer."); - - return XenRef.Create(session.proxy.vdi_introduce(session.uuid, (_uuid != null) ? _uuid : "", (_name_label != null) ? _name_label : "", (_name_description != null) ? _name_description : "", (_sr != null) ? _sr : "", vdi_type_helper.ToString(_type), _sharable, _read_only, Maps.convert_to_proxy_string_string(_other_config), (_location != null) ? _location : "", Maps.convert_to_proxy_string_string(_xenstore_data), Maps.convert_to_proxy_string_string(_sm_config)).parse()); - } - - /// - /// Backward compatibility for VDI.async_introduce in XenServer 6.0. - /// - public static XenRef async_introduce(Session session, string _uuid, string _name_label, string _name_description, string _sr, vdi_type _type, bool _sharable, bool _read_only, Dictionary _other_config, string _location, Dictionary _xenstore_data, Dictionary _sm_config) - { - if (Helper.APIVersionMeets(session, API_Version.API_1_10)) - System.Diagnostics.Debug.Assert(false, "Cannot use this call on XenServer 6.1 or newer."); - - return XenRef.Create(session.proxy.async_vdi_introduce(session.uuid, (_uuid != null) ? _uuid : "", (_name_label != null) ? _name_label : "", (_name_description != null) ? _name_description : "", (_sr != null) ? _sr : "", vdi_type_helper.ToString(_type), _sharable, _read_only, Maps.convert_to_proxy_string_string(_other_config), (_location != null) ? _location : "", Maps.convert_to_proxy_string_string(_xenstore_data), Maps.convert_to_proxy_string_string(_sm_config)).parse()); - } - - /// - /// Backward compatibility for VDI.db_introduce in XenServer 6.0. - /// - public static XenRef db_introduce(Session session, string _uuid, string _name_label, string _name_description, string _sr, vdi_type _type, bool _sharable, bool _read_only, Dictionary _other_config, string _location, Dictionary _xenstore_data, Dictionary _sm_config) - { - if (Helper.APIVersionMeets(session, API_Version.API_1_10)) - System.Diagnostics.Debug.Assert(false, "Cannot use this call on XenServer 6.1 or newer."); - - return XenRef.Create(session.proxy.vdi_db_introduce(session.uuid, (_uuid != null) ? _uuid : "", (_name_label != null) ? _name_label : "", (_name_description != null) ? _name_description : "", (_sr != null) ? _sr : "", vdi_type_helper.ToString(_type), _sharable, _read_only, Maps.convert_to_proxy_string_string(_other_config), (_location != null) ? _location : "", Maps.convert_to_proxy_string_string(_xenstore_data), Maps.convert_to_proxy_string_string(_sm_config)).parse()); - } - - /// - /// Backward compatibility for VDI.async_db_introduce in XenServer 6.0. - /// - public static XenRef async_db_introduce(Session session, string _uuid, string _name_label, string _name_description, string _sr, vdi_type _type, bool _sharable, bool _read_only, Dictionary _other_config, string _location, Dictionary _xenstore_data, Dictionary _sm_config) - { - if (Helper.APIVersionMeets(session, API_Version.API_1_10)) - System.Diagnostics.Debug.Assert(false, "Cannot use this call on XenServer 6.1 or newer."); - - return XenRef.Create(session.proxy.async_vdi_db_introduce(session.uuid, (_uuid != null) ? _uuid : "", (_name_label != null) ? _name_label : "", (_name_description != null) ? _name_description : "", (_sr != null) ? _sr : "", vdi_type_helper.ToString(_type), _sharable, _read_only, Maps.convert_to_proxy_string_string(_other_config), (_location != null) ? _location : "", Maps.convert_to_proxy_string_string(_xenstore_data), Maps.convert_to_proxy_string_string(_sm_config)).parse()); - } - } - - public partial class VM - { - /// - /// Backward compatibility for VM.create_new_blob in XenServer 6.0. - /// - public static XenRef create_new_blob(Session session, string _vm, string _name, string _mime_type) - { - if (Helper.APIVersionMeets(session, API_Version.API_1_10)) - System.Diagnostics.Debug.Assert(false, "Cannot use this call on XenServer 6.1 or newer."); - - return XenRef.Create(session.proxy.vm_create_new_blob(session.uuid, (_vm != null) ? _vm : "", (_name != null) ? _name : "", (_mime_type != null) ? _mime_type : "").parse()); - } - - /// - /// Backward compatibility for VM.async_create_new_blob in XenServer 6.0. - /// - public static XenRef async_create_new_blob(Session session, string _vm, string _name, string _mime_type) - { - if (Helper.APIVersionMeets(session, API_Version.API_1_10)) - System.Diagnostics.Debug.Assert(false, "Cannot use this call on XenServer 6.1 or newer."); - - return XenRef.Create(session.proxy.async_vm_create_new_blob(session.uuid, (_vm != null) ? _vm : "", (_name != null) ? _name : "", (_mime_type != null) ? _mime_type : "").parse()); - } - } -} diff --git a/csharp/src/XenServer.csproj.footer b/csharp/src/XenServer.csproj.footer index 8f2512d..70676f4 100644 --- a/csharp/src/XenServer.csproj.footer +++ b/csharp/src/XenServer.csproj.footer @@ -1,4 +1,3 @@ - diff --git a/java/OMakefile b/java/OMakefile index 8ea32fe..84b7374 100644 --- a/java/OMakefile +++ b/java/OMakefile @@ -44,9 +44,7 @@ else COMPILE_JAVA = yes export -OCAMLPACKS += str -OCamlProgram(main$(EXE), main ../licence) - +OCamlProgram(main, main ../licence ../CommonFunctions) LicenceJava(dir) = $(INSTALL) ../LICENSE $(dir)/LICENSE.txt @@ -62,13 +60,8 @@ Brand(src, dst) = $(INSTALL) $(JAVATMP_DIR)/t-$(basename $(dst)) $(dst) -$(JAVATMP_DIR)/README.txt: - mkdir -p $(JAVATMP_DIR) - Brand(README.dist, $@) - - .PHONY: java_bindings_all -java_bindings_all: $(glob samples/*.java) main$(EXE) $(JAVATMP_DIR)/README.txt +java_bindings_all: main if $(equal $(COMPILE_JAVA), yes) Empty($(JAVAGEN_DIR) $(JAVASRC_DIR) $(JAVABIN_DIR) $(JAVADOC_DIR)) Brand(lib/Makefile.dist, $(JAVAGEN_DIR)/Makefile) @@ -76,9 +69,10 @@ java_bindings_all: $(glob samples/*.java) main$(EXE) $(JAVATMP_DIR)/README.txt $(INSTALL) lib/com/xensource/xenapi/*.java $(JAVAGEN_DIR)/com/xensource/xenapi Brand(lib/com/xensource/xenapi/Connection.java, $(JAVAGEN_DIR)/com/xensource/xenapi/Connection.java) $(INSTALL) $(XMLRPC_DIST)/{xmlrpc-common-3.1,xmlrpc-client-3.1,ws-commons-util-1.0.2}.jar $(JAVAGEN_DIR) - ./main$(EXE) $(JAVAGEN_DIR) - make -C $(JAVAGEN_DIR) all docs cleanclass + ./main $(JAVAGEN_DIR) + make -C $(JAVAGEN_DIR) all docs cleanclass mv $(JAVAGEN_DIR)/*.jar $(JAVABIN_DIR) + Brand(README.dist, $(JAVATMP_DIR)/README.txt) $(INSTALL) $(JAVATMP_DIR)/README.txt $(JAVABIN_DIR) LicenceJava($(JAVABIN_DIR)) mv $(JAVAGEN_DIR)/doc/* $(JAVADOC_DIR) @@ -87,7 +81,8 @@ java_bindings_all: $(glob samples/*.java) main$(EXE) $(JAVATMP_DIR)/README.txt $(INSTALL) $(JAVATMP_DIR)/README.txt $(JAVASRC_DIR) LicenceJava($(JAVASRC_DIR)) Empty($(JAVASAM_DIR)) - $(INSTALL) $^ $(JAVASAM_DIR) + $(INSTALL) samples/*.java $(JAVASAM_DIR) + $(INSTALL) $(JAVATMP_DIR)/README.txt $(JAVASAM_DIR) LicenceJava($(JAVASAM_DIR)) else Empty($(JAVASRC_DIR) $(JAVABIN_DIR) $(JAVADOC_DIR)) @@ -102,6 +97,6 @@ java_folders: java_bindings_all .PHONY: clean clean: rm -f *.annot *.o *.cmi *.cmx *.cmo *.cma *.cmxa *.run *.omc - rm -f main$(EXE) + rm -f main .DEFAULT: java_bindings_all diff --git a/java/lib/com/xensource/xenapi/Connection.java b/java/lib/com/xensource/xenapi/Connection.java index 95edeb0..d822057 100644 --- a/java/lib/com/xensource/xenapi/Connection.java +++ b/java/lib/com/xensource/xenapi/Connection.java @@ -325,7 +325,7 @@ public String getSessionReference() /** * The (auto-generated parts of) the bindings dispatch XMLRPC calls on this Connection's client through this method. */ - Map dispatch(String method_call, Object[] method_params) throws XmlRpcException, XenAPIException + protected Map dispatch(String method_call, Object[] method_params) throws XmlRpcException, XenAPIException { Map response = (Map) client.execute(method_call, method_params); diff --git a/java/main.ml b/java/main.ml index 4b461fe..b1ff2d0 100644 --- a/java/main.ml +++ b/java/main.ml @@ -35,6 +35,7 @@ open Str open Datamodel_types open Dm_api +open CommonFunctions module DT = Datamodel_types module DU = Datamodel_utils @@ -189,30 +190,17 @@ let get_java_type_or_void = function (* Here are a lot of functions which ask questions of the messages associated with*) (* objects, the answers to which are helpful when generating the corresponding java*) -(* functions. For instance get_method_static takes an object's message, and*) +(* functions. For instance is_method_static takes an object's message, and*) (* determines whether it should be static or not in java, by looking at whether*) (* it has a self parameter or not.*) -(*Is the method static?*) -let get_method_static message = - match message.msg_params with - | [] -> true - | {param_name="self"}::_ -> false - | {param_type=ty}::_ -> not (ty = Ref message.msg_obj_name) - - -let get_method_static_string message = - if get_method_static message - then "static " - else "" (*Similar functions for deprecation of methods*) let get_method_deprecated message = message.msg_release.internal_deprecated_since <> None;; let get_method_deprecated_string message = - if get_method_deprecated message - then "@Deprecated" + if get_method_deprecated message then "@Deprecated" else "";; let get_method_param {param_type=ty; param_name=name} = @@ -220,31 +208,18 @@ let get_method_param {param_type=ty; param_name=name} = let name = camel_case name in sprintf "%s %s" ty name -let get_method_param_for_call {param_type=ty; param_name=name} = - let name = camel_case name in - sprintf "%s" name;; - -let get_method_params_list message = - if get_method_static message - then message.msg_params - else List.tl message.msg_params - -let get_method_params_for_signature message = - let params = get_method_params_list message in +let get_method_params_for_signature params = (String.concat ", " ("Connection c" :: (List.map get_method_param params))) -let get_method_params_for_call message = - let params = get_method_params_list message in - (String.concat ", " ("c" :: (List.map get_method_param_for_call params)));; - -let get_method_params_for_xml message = +let get_method_params_for_xml message params= let f = function | {param_type=Record _; param_name=name} -> (camel_case name) ^ "_map" - | {param_name=name} -> camel_case name in - if get_method_static message - then List.map f message.msg_params - else "this.ref" :: (List.map f (List.tl message.msg_params)) - + | {param_name=name} -> camel_case name in + match params with + | [] -> if is_method_static message then [] + else ["this.ref"] + | _ -> if is_method_static message then List.map f params + else "this.ref"::(List.map f params) let gen_method_return_cast message = match message.msg_result with | None -> sprintf "" @@ -262,46 +237,46 @@ let rec range = function (* Here is the main method generating function.*) -let gen_method file cls message async_version = +let gen_method file cls message params async_version = let deprecated_string = get_method_deprecated_string message in - let return_type = - if (String.lowercase cls.name) = "event" && (String.lowercase message.msg_name) = "from" then "EventBatch" - else get_java_type_or_void message.msg_result in - let method_static = get_method_static_string message in + let return_type = if (String.lowercase cls.name) = "event" && (String.lowercase message.msg_name) = "from" then "EventBatch" + else get_java_type_or_void message.msg_result in + let method_static = if is_method_static message then "static " else "" in let method_name = camel_case message.msg_name in - let method_params = get_method_params_for_signature message in - let session_req = message.msg_session in + let paramString = get_method_params_for_signature params in let default_errors = ["BadServerResponse"; "XenAPIException"; "XmlRpcException"] in let err_string = String.concat ",\n " (default_errors @ (List.map (fun err -> "Types." ^ (exception_class_case err.err_name)) message.msg_errors)) in + let publishInfo = get_published_info_message message cls in fprintf file " /**\n"; fprintf file " * %s\n" message.msg_doc; - if (get_method_deprecated message) then - fprintf file " * @deprecated\n"; + if not (publishInfo = "") then fprintf file " * %s\n" publishInfo; + if (get_method_deprecated message) then fprintf file " * @deprecated\n"; fprintf file " *\n"; - List.iter - (fun {param_name=name; param_doc=desc} -> fprintf file " * @param %s %s\n" (camel_case name) desc) - (get_method_params_list message); + List.iter (fun x -> let paramPublishInfo = get_published_info_param message x in + fprintf file " * @param %s %s%s\n" + (camel_case x.param_name) + x.param_doc + (if paramPublishInfo = "" then "" else " "^paramPublishInfo)) + params; if async_version then fprintf file " * @return Task\n" else (match message.msg_result with - | None -> () - | Some (_, desc) -> - fprintf file " * @return %s\n" desc); + | None -> () + | Some (_, desc) -> fprintf file " * @return %s\n" desc); fprintf file " */\n"; - if async_version then - fprintf file " %s public %sTask %s(%s) throws\n" deprecated_string method_static (method_name^"Async") method_params - + if async_version then + fprintf file " %s public %sTask %sAsync(%s) throws\n" deprecated_string method_static method_name paramString else - fprintf file " %s public %s%s %s(%s) throws\n" deprecated_string method_static return_type method_name method_params; + fprintf file " %s public %s%s %s(%s) throws\n" deprecated_string method_static return_type method_name paramString; fprintf file " %s {\n" err_string; @@ -310,30 +285,26 @@ let gen_method file cls message async_version = else fprintf file " String method_call = \"%s.%s\";\n" message.msg_obj_name message.msg_name; - if not session_req - then () - else fprintf file " String session = c.getSessionReference();\n"; + if message.msg_session then + fprintf file " String session = c.getSessionReference();\n" + else (); let record_params = List.filter (function {param_type=Record _} -> true | _ -> false) message.msg_params in List.iter - (fun {param_name=s} -> - let name = camel_case s in - fprintf file " Map %s_map = %s.toMap();\n" name name) - record_params; + (fun {param_name=s} -> + let name = camel_case s in + fprintf file " Map %s_map = %s.toMap();\n" name name) + record_params; fprintf file " Object[] method_params = {"; - let method_params_list = if session_req - then "session"::(get_method_params_for_xml message) - else (get_method_params_for_xml message) in - - (* let method_params_list = (get_method_params_for_xml message) in*) + let methodParamsList = if message.msg_session then + "session"::(get_method_params_for_xml message params) + else + (get_method_params_for_xml message params) in - let method_params_list = - List.map (fun s -> sprintf "Marshalling.toXMLRPC(%s)" s) method_params_list in - - output_string file (String.concat ", " method_params_list); + output_string file (String.concat ", " (List.map (fun s -> sprintf "Marshalling.toXMLRPC(%s)" s) methodParamsList)); fprintf file "};\n"; @@ -351,78 +322,17 @@ let gen_method file cls message async_version = fprintf file " }\n\n" -(* Here is the main method generating function.*) -let gen_versioned_method file cls message versioned_message async_version = - let deprecated_string = get_method_deprecated_string message in - let return_type = - if (String.lowercase cls.name) = "event" && (String.lowercase message.msg_name) = "from" then "EventBatch" - else get_java_type_or_void message.msg_result in - let method_static = get_method_static_string message in - let versioned_name = camel_case versioned_message.msg_name in - let method_params = get_method_params_for_signature versioned_message in - let session_req = message.msg_session in - let default_errors = ["BadServerResponse"; - "XmlRpcException"; - "XenAPIException"] in - let err_string = String.concat ",\n " (default_errors @ (List.map - (fun err -> "Types." ^ (exception_class_case err.err_name)) message.msg_errors)) in - - if async_version then - fprintf file " %s private %s%s %s(%s) throws\n" deprecated_string method_static "Task" (versioned_name^"Async") method_params - - else - fprintf file " %s private %s%s %s(%s) throws\n" deprecated_string method_static return_type versioned_name method_params; - - fprintf file " %s {\n" err_string; - - if async_version then - fprintf file " String method_call = \"Async.%s.%s\";\n" message.msg_obj_name message.msg_name - else - fprintf file " String method_call = \"%s.%s\";\n" message.msg_obj_name message.msg_name; - - if not session_req - then () - else fprintf file " String session = c.getSessionReference();\n"; - - let record_params = List.filter (function {param_type=Record _} -> true | _ -> false) message.msg_params in - - List.iter - (fun {param_name=s} -> - let name = camel_case s in - fprintf file " Map %s_map = %s.toMap();\n" name name) - record_params; - - fprintf file " Object[] method_params = {"; - - let method_params_list = if session_req - then "session"::(get_method_params_for_xml versioned_message) - else (get_method_params_for_xml versioned_message) in - - (* let method_params_list = (get_method_params_for_xml message) in*) - - let method_params_list = - List.map (fun s -> sprintf "Marshalling.toXMLRPC(%s)" s) method_params_list in - - output_string file (String.concat ", " method_params_list); - - fprintf file "};\n"; - fprintf file " Map response = c.dispatch(method_call, method_params);\n"; - fprintf file " Object result = response.get(\"Value\");\n" ; - - if async_version then - fprintf file " return Types.toTask(result);\n" - else - gen_method_return file cls message; - - fprintf file " }\n\n" -;; - - (*Some methods have an almost identical asynchronous counterpart, which returns*) (* a Task reference rather than its usual return value*) let gen_method_and_asynchronous_counterpart file cls message = - if message.msg_async then gen_method file cls message true; - gen_method file cls message false;; + let methodParams = get_method_params_list message in + let generator = fun x -> (if message.msg_async then gen_method file cls message x true; + gen_method file cls message x false) in + match methodParams with + | [] -> generator [] + | _ -> let paramGroups = gen_param_groups message methodParams in + List.iter generator paramGroups + ;; (* Generate the record *) @@ -432,21 +342,22 @@ let gen_method_and_asynchronous_counterpart file cls message = (* functions are in fact implemented as three sets of three mutual recursions,*) (* which take the trees apart. *) -let gen_record_field file prefix field = +let gen_record_field file prefix field cls = let ty = get_java_type field.ty in - let name = String.concat "_" (List.rev (field.field_name :: prefix)) in - let name = camel_case name in + let name = camel_case (String.concat "_" (List.rev (field.field_name :: prefix))) in + let publishInfo = get_published_info_field field cls in fprintf file " /**\n"; fprintf file " * %s\n" field.field_description; + if not (publishInfo = "") then fprintf file " * %s\n" publishInfo; fprintf file " */\n"; fprintf file " public %s %s;\n" ty name -let rec gen_record_namespace file prefix (name, contents) = - List.iter (gen_record_contents file (name::prefix)) contents; +let rec gen_record_namespace file prefix (name, contents) cls = + List.iter (gen_record_contents file (name::prefix) cls) contents; -and gen_record_contents file prefix = function - | Field f -> gen_record_field file prefix f - | Namespace (n,cs) -> gen_record_namespace file prefix (n,cs);; +and gen_record_contents file prefix cls = function + | Field f -> gen_record_field file prefix f cls + | Namespace (n,cs) -> gen_record_namespace file prefix (n,cs) cls;; (***) @@ -526,7 +437,7 @@ let gen_record file cls = fprintf file " return map;\n"; fprintf file " }\n\n"; - List.iter (gen_record_contents file []) contents; + List.iter (gen_record_contents file [] cls) contents; if (cls.name="event") then begin fprintf file " /**\n"; @@ -557,6 +468,7 @@ let gen_class cls = let class_name = class_case cls.name in let methods = cls.messages in let file = open_out (class_name ^ ".java") in + let publishInfo = get_published_info_class cls in print_license file; fprintf file "package com.xensource.xenapi; @@ -577,6 +489,7 @@ import org.apache.xmlrpc.XmlRpcException; "; fprintf file "/**\n"; fprintf file " * %s\n" cls.description; + if not (publishInfo = "") then fprintf file " * %s\n" publishInfo; fprintf file " *\n"; fprintf file " * @author Citrix Systems, Inc.\n"; fprintf file " */\n"; diff --git a/java/samples/AsyncVMCreate.java b/java/samples/AsyncVMCreate.java index 7b347d4..1b0a872 100644 --- a/java/samples/AsyncVMCreate.java +++ b/java/samples/AsyncVMCreate.java @@ -59,6 +59,9 @@ public static void RunTest(ILog logger, TargetServer target) throws Exception private static void createVM(String newvmname) throws Exception { + /*First check we can start an HVM on the master*/ + checkMasterHvmCapable(); + VM template = getFirstWindowsTemplate(); logln("Template found: " + template.getNameLabel(connection)); diff --git a/java/samples/CreateVM.java b/java/samples/CreateVM.java index e9b87b2..ec728b5 100644 --- a/java/samples/CreateVM.java +++ b/java/samples/CreateVM.java @@ -58,6 +58,9 @@ public static void RunTest(ILog logger, TargetServer server) throws Exception private static void createVM(String newVmName) throws Exception { + /*First check we can start an HVM on the master*/ + checkMasterHvmCapable(); + VM template = getFirstWindowsTemplate(); logln("Template found: " + template.getNameLabel(connection)); diff --git a/java/samples/TestBase.java b/java/samples/TestBase.java index 45d7549..1e0f47e 100644 --- a/java/samples/TestBase.java +++ b/java/samples/TestBase.java @@ -32,15 +32,7 @@ import java.util.Map; import java.util.Set; -import com.xensource.xenapi.APIVersion; -import com.xensource.xenapi.Connection; -import com.xensource.xenapi.Network; -import com.xensource.xenapi.Pool; -import com.xensource.xenapi.SR; -import com.xensource.xenapi.Session; -import com.xensource.xenapi.Task; -import com.xensource.xenapi.Types; -import com.xensource.xenapi.VM; +import com.xensource.xenapi.*; public abstract class TestBase { @@ -159,4 +151,25 @@ protected static Network getFirstNetwork() throws Exception throw new Exception("No networks found!"); } + + /** + * Checks whether the master has hvm capabilities. + */ + protected static void checkMasterHvmCapable() throws Exception + { + logln("checking master has hvm capabilities..."); + Pool pool = (Pool) Pool.getAll(connection).toArray()[0]; + Host master = pool.getMaster(connection); + Set capabilities = master.getCapabilities(connection); + + Boolean hvmCapable = false; + for (String s: capabilities) + if (s.contains("hvm")) { + hvmCapable = true; + break; + } + + if (!hvmCapable) + throw new Exception("Master has no hvm capabilities!"); + } } diff --git a/mk/Makefile b/mk/Makefile index 01ba91d..c5ca7c9 100644 --- a/mk/Makefile +++ b/mk/Makefile @@ -133,15 +133,22 @@ endif .PHONY: powershell-module powershell-module: $(MY_OBJ_DIR)/XenServerPowerShell.dll mkdir -p $(SDK_PS_FOLDER)/XenServerPSModule - cp $(MY_OBJ_DIR)/{*.dll,*.ps1,*.ps1xml} $(SDK_PS_FOLDER)/XenServerPSModule + cp $(MY_OBJ_DIR)/{*.dll,*.ps1xml} $(SDK_PS_FOLDER)/XenServerPSModule + cp $(MY_OBJ_DIR)/Initialize-Environment.ps1 $(SDK_PS_FOLDER)/XenServerPSModule sed -e 's/@PRODUCT_VERSION@/$(PRODUCT_VERSION)/g' \ -e 's/@PRODUCT_GUID@/$(PRODUCT_GUID)/g' \ $(REPO)/powershell/XenServerPSModule.psd1 > $(SDK_PS_FOLDER)/XenServerPSModule/XenServerPSModule.psd1 cp $(SDK_PS_FOLDER)/src/*.txt $(SDK_PS_FOLDER)/XenServerPSModule $(INSTALL) $(XMLRPCLICENSE) $(SDK_PS_FOLDER)/XenServerPSModule/LICENSE.CookComputing.XmlRpcV2 +.PHONY: powershell_samples +powershell_samples: $(MY_OBJ_DIR)/XenServerPowerShell.dll + mkdir -p $(SDK_PS_FOLDER)/samples + cp $(MY_OBJ_DIR)/*.ps1 $(SDK_PS_FOLDER)/samples + rm -f $(SDK_PS_FOLDER)/samples/Initialize-Environment.ps1 + .PHONY: bins -bins: omake-phase powershell-module csharp-bin +bins: omake-phase powershell-module powershell_samples csharp-bin mkdir -p $(MY_OUTPUT_DIR) cp $(BINDINGS_TMP)/XenCenterBindings.zip $(MY_OUTPUT_DIR)/XenCenterBindings-$(BUILD_NUMBER).zip cp $(MY_OBJ_DIR)/FriendlyErrorNames.Designer.cs $(SDK_NET_FOLDER)/src diff --git a/powershell/Initialize-Environment.ps1 b/powershell/Initialize-Environment.ps1 index ee4fb7f..b411b84 100644 --- a/powershell/Initialize-Environment.ps1 +++ b/powershell/Initialize-Environment.ps1 @@ -28,12 +28,6 @@ # OF THE POSSIBILITY OF SUCH DAMAGE. # -# -# Please do not customize this script; your changes will be lost on upgrade. -# -# Instead, create and customize the file XenServerProfile.ps1. -# Put it in $env:windir\system32\WindowsPowerShell\v1.0 for system-wide # configuration, or $env:UserProfile\Documents\WindowsPowerShell # for per-user configuration. -# if (Get-Variable XenServer_Environment_Initialized -ValueOnly -ErrorAction SilentlyContinue) { diff --git a/powershell/OMakefile b/powershell/OMakefile index cacec80..c2e3734 100644 --- a/powershell/OMakefile +++ b/powershell/OMakefile @@ -35,22 +35,18 @@ else COMPILE_POWERSHELL = yes export -OCamlProgram(gen_powershell_binding, gen_powershell_binding common_functions ../licence) +OCamlProgram(gen_powershell_binding, gen_powershell_binding common_functions ../licence ../CommonFunctions) .PHONY: gen_powershell_bindings -gen_powershell_bindings: gen_powershell_binding$(EXE) +gen_powershell_bindings: gen_powershell_binding rm -Rf $(POWERSHELL_GEN) mkdir -p $(POWERSHELL_GEN) if $(equal $(COMPILE_POWERSHELL), yes) - ./gen_powershell_binding$(EXE) $(POWERSHELL_GEN) - -.PHONY: powershell_samples -powershell_samples: - mkdir -p $(SDK_PS_FOLDER)/samples && $(INSTALL) samples/*.ps1 $(SDK_PS_FOLDER)/samples + ./gen_powershell_binding $(POWERSHELL_GEN) .PHONY: clean clean: rm -f *.annot *.o *.cmi *.cmx *.cmo *.cma *.cmxa *.run *.opt *.omc - rm -f gen_powershell_binding$(EXE) + rm -f gen_powershell_binding .DEFAULT: gen_powershell_bindings diff --git a/powershell/XenServerPSModule.psd1 b/powershell/XenServerPSModule.psd1 old mode 100644 new mode 100755 index 14b0230..2046cc3 --- a/powershell/XenServerPSModule.psd1 +++ b/powershell/XenServerPSModule.psd1 @@ -58,9 +58,7 @@ ScriptsToProcess = @('Initialize-Environment.ps1') TypesToProcess = @('XenServer.types.ps1xml') FormatsToProcess = @('XenServer.format.ps1xml') FileList = @('about_XenServer.help.txt', - 'AutomatedTestCore.ps1', - 'CookComputing.XmlRpcV2.dll', - 'HttpTest.ps1', + 'CookComputing.XmlRpcV2.dll', 'Initialize-Environment.ps1', 'LICENSE.CookComputing.XmlRpcV2', 'LICENSE.txt', @@ -68,8 +66,8 @@ FileList = @('about_XenServer.help.txt', 'XenServer.dll', 'XenServer.format.ps1xml', 'XenServer.types.ps1xml', - 'XenServerPowerShell.psd1', - 'XenServerPowerShell.dll') + 'XenServerPowerShell.dll', + 'XenServerPSModule.psd1') #Public interface FunctionsToExport = '' diff --git a/powershell/about_XenServer.help.txt b/powershell/about_XenServer.help.txt old mode 100644 new mode 100755 index 45d8d95..0f92c61 --- a/powershell/about_XenServer.help.txt +++ b/powershell/about_XenServer.help.txt @@ -10,6 +10,10 @@ For a list of all possible commands type: Get-Command -Module XenServerPSModule +You may want to create the file XenServerProfile.ps1 to set up your +environment when the XenServer PowerShell Module is loaded. Put it in +$env:windir\system32\WindowsPowerShell\v1.0 for system-wide configuration, +or $env:UserProfile\Documents\WindowsPowerShell for per-user configuration. Many XenServer cmdlets allow you to identify target objects in several different ways. For example a VM could be identified by its uuid, name, diff --git a/powershell/gen_powershell_binding.ml b/powershell/gen_powershell_binding.ml index 55a35ef..1ed83b3 100644 --- a/powershell/gen_powershell_binding.ml +++ b/powershell/gen_powershell_binding.ml @@ -36,6 +36,7 @@ open Datamodel open Datamodel_types open Dm_api open Common_functions +open CommonFunctions module DT = Datamodel_types module DU = Datamodel_utils @@ -288,6 +289,7 @@ and gen_binding obj = match obj with {name=classname; description = description; messages=messages; contents=contents; gen_constructor_destructor=gen_const_dest} -> + let messages = List.filter (fun x -> not ((get_first_release x.msg_release.internal) = "")) messages in let partNew = List.partition (fun x -> is_constructor x) messages in let constructors = fst partNew in let partDest = List.partition (fun x -> is_destructor x) (snd partNew) in