From 953c02c79235069b64200b7290f0dd44aeb8d704 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 24 Jun 2011 17:51:30 +0200 Subject: [PATCH] Feature #696: Upgraded OCA (Ruby) API to match new filter functionality in pool.info methods --- src/oca/ruby/OpenNebula/ImagePool.rb | 23 +++++++++++++-- src/oca/ruby/OpenNebula/Pool.rb | 29 ++++++++++++++++++- src/oca/ruby/OpenNebula/TemplatePool.rb | 24 ++++++++++++--- src/oca/ruby/OpenNebula/VirtualMachinePool.rb | 21 ++++++++++++-- src/oca/ruby/OpenNebula/VirtualNetworkPool.rb | 23 +++++++++++++-- 5 files changed, 107 insertions(+), 13 deletions(-) diff --git a/src/oca/ruby/OpenNebula/ImagePool.rb b/src/oca/ruby/OpenNebula/ImagePool.rb index 2d60908b63..4cec6b3840 100644 --- a/src/oca/ruby/OpenNebula/ImagePool.rb +++ b/src/oca/ruby/OpenNebula/ImagePool.rb @@ -47,9 +47,26 @@ module OpenNebula # XML-RPC Methods for the Image Object ####################################################################### - # Retrieves all or part of the Images in the pool. - def info() - super(IMAGE_POOL_METHODS[:info],@user_id) + # Retrieves all or part of the VirtualMachines in the pool. + def info(*args) + case args.size + when 0 + info_filter(IMAGE_POOL_METHODS[:info],@user_id,-1,-1) + when 3 + info_filter(IMAGE_POOL_METHODS[:info],args[0],args[1],args[2]) + end + end + + def info_all() + return super(IMAGE_POOL_METHODS[:info]) + end + + def info_mine() + return super(IMAGE_POOL_METHODS[:info]) + end + + def info_group() + return super(IMAGE_POOL_METHODS[:info]) end end end diff --git a/src/oca/ruby/OpenNebula/Pool.rb b/src/oca/ruby/OpenNebula/Pool.rb index 30fa180c51..58c342e547 100644 --- a/src/oca/ruby/OpenNebula/Pool.rb +++ b/src/oca/ruby/OpenNebula/Pool.rb @@ -22,6 +22,10 @@ module OpenNebula include Enumerable protected + # Constants for info queries (include/RequestManagerPoolInfoFilter.h) + INFO_GROUP = -1 + INFO_ALL = -2 + INFO_MINE = -3 #pool:: _String_ XML name of the root element #element:: _String_ XML name of the Pool elements @@ -48,13 +52,36 @@ module OpenNebula ####################################################################### # Common XML-RPC Methods for all the Pool Types ####################################################################### + + #Gets the pool without any filter. Host, Group and User Pools + # xml_method:: _String_ the name of the XML-RPC method + def info(xml_method) + return xmlrpc_info(xml_method) + end + def info_all(xml_method) + return xmlrpc_info(xml_method,INFO_ALL,-1,-1) + end + + def info_mine(xml_method) + return xmlrpc_info(xml_method,INFO_MINE,-1,-1) + end + + def info_group(xml_method) + return xmlrpc_info(xml_method,INFO_GROUP,-1,-1) + end + + def info_filter(xml_method, who, start_id, end_id) + return xmlrpc_info(xml_method,who, start_id, end_id) + end + + private # Calls to the corresponding info method to retreive the pool # representation in XML format # xml_method:: _String_ the name of the XML-RPC method # args:: _Array_ with additional arguments for the info call # [return] nil in case of success or an Error object - def info(xml_method,*args) + def xmlrpc_info(xml_method,*args) rc = @client.call(xml_method,*args) if !OpenNebula.is_error?(rc) diff --git a/src/oca/ruby/OpenNebula/TemplatePool.rb b/src/oca/ruby/OpenNebula/TemplatePool.rb index 8cebdd8877..c5174036bc 100644 --- a/src/oca/ruby/OpenNebula/TemplatePool.rb +++ b/src/oca/ruby/OpenNebula/TemplatePool.rb @@ -46,10 +46,26 @@ module OpenNebula # --------------------------------------------------------------------- # XML-RPC Methods for the Template Object # --------------------------------------------------------------------- + # Retrieves all or part of the VirtualMachines in the pool. + def info(*args) + case args.size + when 0 + info_filter(TEMPLATE_POOL_METHODS[:info],@user_id,-1,-1) + when 3 + info_filter(TEMPLATE_POOL_METHODS[:info],args[0],args[1],args[2]) + end + end - # Retrieves all the Templates in the pool. - def info() - super(TEMPLATE_POOL_METHODS[:info], @user_id) + def info_all() + return super(TEMPLATE_POOL_METHODS[:info]) + end + + def info_mine() + return super(TEMPLATE_POOL_METHODS[:info]) + end + + def info_group() + return super(TEMPLATE_POOL_METHODS[:info]) end end -end \ No newline at end of file +end diff --git a/src/oca/ruby/OpenNebula/VirtualMachinePool.rb b/src/oca/ruby/OpenNebula/VirtualMachinePool.rb index 766fd202dc..7a61c1ae98 100644 --- a/src/oca/ruby/OpenNebula/VirtualMachinePool.rb +++ b/src/oca/ruby/OpenNebula/VirtualMachinePool.rb @@ -48,8 +48,25 @@ module OpenNebula ####################################################################### # Retrieves all or part of the VirtualMachines in the pool. - def info() - super(VM_POOL_METHODS[:info],@user_id) + def info(*args) + case args.size + when 0 + info_filter(VM_POOL_METHODS[:info],@user_id,-1,-1) + when 3 + info_filter(VM_POOL_METHODS[:info],args[0],args[1],args[2]) + end + end + + def info_all() + return super(VM_POOL_METHODS[:info]) + end + + def info_mine() + return super(VM_POOL_METHODS[:info]) + end + + def info_group() + return super(VM_POOL_METHODS[:info]) end end end diff --git a/src/oca/ruby/OpenNebula/VirtualNetworkPool.rb b/src/oca/ruby/OpenNebula/VirtualNetworkPool.rb index 0e41cc99ba..4267ac1830 100644 --- a/src/oca/ruby/OpenNebula/VirtualNetworkPool.rb +++ b/src/oca/ruby/OpenNebula/VirtualNetworkPool.rb @@ -47,9 +47,26 @@ module OpenNebula # XML-RPC Methods for the Virtual Network Object ####################################################################### - # Retrieves all or part of the VirtualNetwork in the pool. - def info() - super(VN_POOL_METHODS[:info],@user_id) + # Retrieves all or part of the VirtualMachines in the pool. + def info(*args) + case args.size + when 0 + info_filter(VN_POOL_METHODS[:info],@user_id,-1,-1) + when 3 + info_filter(VN_POOL_METHODS[:info],args[0],args[1],args[2]) + end + end + + def info_all() + return super(VN_POOL_METHODS[:info]) + end + + def info_mine() + return super(VN_POOL_METHODS[:info]) + end + + def info_group() + return super(VN_POOL_METHODS[:info]) end end end