mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-12 09:17:41 +03:00
Feature #1304: Refactor Pool.rb
This commit is contained in:
parent
5d110819d9
commit
b559426bec
@ -177,15 +177,35 @@ module OpenNebula
|
|||||||
# Common XML-RPC Methods for all the Pool Element Types
|
# Common XML-RPC Methods for all the Pool Element Types
|
||||||
#######################################################################
|
#######################################################################
|
||||||
|
|
||||||
|
# Common client call wrapper. Checks that @pe_id is defined, and
|
||||||
|
# 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)
|
||||||
|
return Error.new('ID not defined') if !@pe_id
|
||||||
|
|
||||||
|
rc = @client.call(xml_method, *args)
|
||||||
|
rc = nil if !OpenNebula.is_error?(rc)
|
||||||
|
|
||||||
|
return rc
|
||||||
|
end
|
||||||
|
|
||||||
# Calls to the corresponding info method to retreive the element
|
# Calls to the corresponding info method to retreive the element
|
||||||
# detailed information in XML format
|
# detailed information in XML format
|
||||||
# xml_method:: _String_ the name of the XML-RPC method
|
#
|
||||||
# root_element:: _String_ Base XML element
|
# @param [String] xml_method the name of the XML-RPC method
|
||||||
# [return] nil in case of success or an Error object
|
# @param [String] root_element Base XML element name
|
||||||
|
#
|
||||||
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
||||||
|
# otherwise
|
||||||
def info(xml_method, root_element)
|
def info(xml_method, root_element)
|
||||||
return Error.new('ID not defined') if !@pe_id
|
return Error.new('ID not defined') if !@pe_id
|
||||||
|
|
||||||
rc = @client.call(xml_method,@pe_id)
|
rc = @client.call(xml_method, @pe_id)
|
||||||
|
|
||||||
if !OpenNebula.is_error?(rc)
|
if !OpenNebula.is_error?(rc)
|
||||||
initialize_xml(rc, root_element)
|
initialize_xml(rc, root_element)
|
||||||
@ -221,14 +241,9 @@ module OpenNebula
|
|||||||
# new_template:: _String_ the new template contents
|
# new_template:: _String_ the new template contents
|
||||||
# [return] nil in case of success or an Error object
|
# [return] nil in case of success or an Error object
|
||||||
def update(xml_method, new_template)
|
def update(xml_method, new_template)
|
||||||
return Error.new('ID not defined') if !@pe_id
|
|
||||||
|
|
||||||
new_template ||= template_xml
|
new_template ||= template_xml
|
||||||
|
|
||||||
rc = @client.call(xml_method,@pe_id, new_template)
|
return call(xml_method, @pe_id, new_template)
|
||||||
rc = nil if !OpenNebula.is_error?(rc)
|
|
||||||
|
|
||||||
return rc
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Calls to the corresponding delete method to remove this element
|
# Calls to the corresponding delete method to remove this element
|
||||||
@ -236,12 +251,7 @@ module OpenNebula
|
|||||||
# xml_method:: _String_ the name of the XML-RPC method
|
# xml_method:: _String_ the name of the XML-RPC method
|
||||||
# [return] nil in case of success or an Error object
|
# [return] nil in case of success or an Error object
|
||||||
def delete(xml_method)
|
def delete(xml_method)
|
||||||
return Error.new('ID not defined') if !@pe_id
|
return call(xml_method,@pe_id)
|
||||||
|
|
||||||
rc = @client.call(xml_method,@pe_id)
|
|
||||||
rc = nil if !OpenNebula.is_error?(rc)
|
|
||||||
|
|
||||||
return rc
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Calls to the corresponding chown method to modify
|
# Calls to the corresponding chown method to modify
|
||||||
@ -251,12 +261,7 @@ module OpenNebula
|
|||||||
# gid:: _Integer_ the new group id. Set to -1 to leave the current one
|
# gid:: _Integer_ the new group id. Set to -1 to leave the current one
|
||||||
# [return] nil in case of success or an Error object
|
# [return] nil in case of success or an Error object
|
||||||
def chown(xml_method, uid, gid)
|
def chown(xml_method, uid, gid)
|
||||||
return Error.new('ID not defined') if !@pe_id
|
return call(xml_method, @pe_id, uid, gid)
|
||||||
|
|
||||||
rc = @client.call(xml_method,@pe_id, uid, gid)
|
|
||||||
rc = nil if !OpenNebula.is_error?(rc)
|
|
||||||
|
|
||||||
return rc
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Calls to the corresponding chmod method to modify
|
# Calls to the corresponding chmod method to modify
|
||||||
@ -290,14 +295,9 @@ module OpenNebula
|
|||||||
# otherwise
|
# otherwise
|
||||||
def chmod(xml_method, owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u,
|
def chmod(xml_method, owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u,
|
||||||
other_m, other_a)
|
other_m, other_a)
|
||||||
return Error.new('ID not defined') if !@pe_id
|
return call(xml_method, @pe_id, owner_u, owner_m,
|
||||||
|
|
||||||
rc = @client.call(xml_method, @pe_id, owner_u, owner_m,
|
|
||||||
owner_a, group_u, group_m, group_a, other_u,
|
owner_a, group_u, group_m, group_a, other_u,
|
||||||
other_m, other_a)
|
other_m, other_a)
|
||||||
rc = nil if !OpenNebula.is_error?(rc)
|
|
||||||
|
|
||||||
return rc
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user