From 9cc2c8f897e1458aad0427b2c38cb2b552f4cbc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 23 Nov 2012 18:27:09 +0100 Subject: [PATCH] Feature #1611: Add default quota info and update methods to ruby oca --- src/oca/ruby/OpenNebula/GroupPool.rb | 25 ++++++++++++++++++++++--- src/oca/ruby/OpenNebula/Pool.rb | 15 +++++++++++++++ src/oca/ruby/OpenNebula/UserPool.rb | 23 +++++++++++++++++++++-- 3 files changed, 58 insertions(+), 5 deletions(-) diff --git a/src/oca/ruby/OpenNebula/GroupPool.rb b/src/oca/ruby/OpenNebula/GroupPool.rb index 20ebdeed08..782243e69c 100644 --- a/src/oca/ruby/OpenNebula/GroupPool.rb +++ b/src/oca/ruby/OpenNebula/GroupPool.rb @@ -25,7 +25,9 @@ module OpenNebula GROUP_POOL_METHODS = { - :info => "grouppool.info" + :info => "grouppool.info", + :quotainfo => "groupquota.info", + :quotaupdate => "groupquota.update" } ####################################################################### @@ -37,18 +39,35 @@ module OpenNebula super('GROUP_POOL','GROUP',client) end - # Factory method to create User objects + # Factory method to create Group objects def factory(element_xml) OpenNebula::Group.new(element_xml,@client) end ####################################################################### - # XML-RPC Methods for the User Object + # XML-RPC Methods for the GroupPool Object ####################################################################### # Retrieves all the Groups in the pool. def info() super(GROUP_POOL_METHODS[:info]) end + + # Gets the default group quota limits + # + # @return [String, OpenNebula::Error] the default group quota in case + # of success, Error otherwise + def get_quota() + return @client.call(GROUP_POOL_METHODS[:quotainfo]) + end + + # Sets the default group quota limits + # @param quota [String] a template (XML or txt) with the new quota limits + # + # @return [nil, OpenNebula::Error] nil in case of success, Error + # otherwise + def set_quota(quota) + return call(GROUP_POOL_METHODS[:quotaupdate], quota) + end end end diff --git a/src/oca/ruby/OpenNebula/Pool.rb b/src/oca/ruby/OpenNebula/Pool.rb index e917f7bb32..3f68d6204e 100644 --- a/src/oca/ruby/OpenNebula/Pool.rb +++ b/src/oca/ruby/OpenNebula/Pool.rb @@ -48,6 +48,21 @@ module OpenNebula # Common XML-RPC Methods for all the Pool Types ####################################################################### + # Common client call wrapper. Returns nil instead of the response + # if it is successful + # + # @param [String] xml_method xml-rpc method + # @param [Array] args any arguments for the xml-rpc method + # + # @return [nil, OpenNebula::Error] nil in case of success, Error + # otherwise + def call(xml_method, *args) + rc = @client.call(xml_method, *args) + rc = nil if !OpenNebula.is_error?(rc) + + return rc + end + #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) diff --git a/src/oca/ruby/OpenNebula/UserPool.rb b/src/oca/ruby/OpenNebula/UserPool.rb index b4d9b733a6..85cf907b93 100644 --- a/src/oca/ruby/OpenNebula/UserPool.rb +++ b/src/oca/ruby/OpenNebula/UserPool.rb @@ -24,7 +24,9 @@ module OpenNebula ####################################################################### USER_POOL_METHODS = { - :info => "userpool.info" + :info => "userpool.info", + :quotainfo => "userquota.info", + :quotaupdate => "userquota.update" } ####################################################################### @@ -42,12 +44,29 @@ module OpenNebula end ####################################################################### - # XML-RPC Methods for the User Object + # XML-RPC Methods for the UserPool Object ####################################################################### # Retrieves all the Users in the pool. def info() super(USER_POOL_METHODS[:info]) end + + # Gets the default user quota limits + # + # @return [String, OpenNebula::Error] the default user quota in case + # of success, Error otherwise + def get_quota() + return @client.call(USER_POOL_METHODS[:quotainfo]) + end + + # Sets the default user quota limits + # @param quota [String] a template (XML or txt) with the new quota limits + # + # @return [nil, OpenNebula::Error] nil in case of success, Error + # otherwise + def set_quota(quota) + return call(USER_POOL_METHODS[:quotaupdate], quota) + end end end