Skip to content

Commit

Permalink
Removing more logic from Requests
Browse files Browse the repository at this point in the history
  • Loading branch information
plribeiro3000 committed Sep 4, 2014
1 parent ff97155 commit ee3ecba
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 42 deletions.
35 changes: 3 additions & 32 deletions lib/fog/compute/xen_server/requests/create_sr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,11 @@ module Fog
module Compute
class XenServer
class Real
#
# Create a storage repository (SR)
#
# @see http://docs.vmd.citrix.com/XenServer/6.0.0/1.0/en_gb/api/?c=SR
#
# @param [String] host_ref host reference
# @param [String] name_label repository label
# @param [String] type storage repository type
# @param [String] name_description storage repository description
# @param [Hash] device_config used to specify block device path, like
# { :device => /dev/sdb } for example
# @param [String] physical_size '0' will use the whole device (FIXME
# needs confirmation)
# @param [String] content_type the type of the SR's content.
# According to Citrix documentation, used only to distinguish ISO
# libraries from other SRs. Set it to 'iso' for storage repositories
# that store a library of ISOs, 'user' or '' (empty) otherwise.
# @see http://docs.vmd.citrix.com/XenServer/6.1.0/1.0/en_gb/reference.html#cli-xe-commands_sr
# @param [String] shared
#
# @return [String] an OpaqueRef to the storage repository
def create_sr(config = {}, extra_params = {})
host_ref = extra_params.delete(:host_ref)
name_label = config[:name]
type = config[:type]
name_description = config[:description]
device_config = extra_params.fetch(:device_config, {})
physical_size = config[:physical_size]
content_type = config[:content_type]
shared = config[:shared]
sm_config = config[:sm_config]
@connection.request({ :parser => Fog::Parsers::XenServer::Base.new, :method => 'SR.create' },
host_ref, device_config, physical_size, name_label, name_description, type,
content_type, shared, sm_config)
extra_params[:host_ref], extra_params[:device_config], config[:physical_size],
config[:name], config[:description], config[:type], config[:content_type],
config[:shared], config[:sm_config])
end
end
end
Expand Down
1 change: 0 additions & 1 deletion lib/fog/compute/xen_server/requests/create_vbd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module Compute
class XenServer
class Real
def create_vbd(config = {}, extra_params = {})
raise ArgumentError.new('Invalid config') if config.nil?
@connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VBD.create'}, config)
end
end
Expand Down
5 changes: 0 additions & 5 deletions lib/fog/compute/xen_server/requests/create_vdi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ module Compute
class XenServer
class Real
def create_vdi(config = {}, extra_params = {})
raise ArgumentError.new('Invalid config') if config.nil?
raise ArgumentError.new('Missing virtual_size attribute') if config[:virtual_size].nil?
raise ArgumentError.new('Missing read_only attribute') if config[:read_only].nil?
raise ArgumentError.new('Missing type attribute') if config[:type].nil?
raise ArgumentError.new('Missing sharable attribute') if config[:sharable].nil?
raise ArgumentError.new('Missing other_config attribute') if config[:other_config].nil?
raise ArgumentError.new('Missing storage_repository attribute') if config[:SR].nil?
@connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VDI.create'}, config)
end
Expand Down
5 changes: 1 addition & 4 deletions lib/fog/compute/xen_server/requests/create_vlan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ class Real
# @see http://docs.vmd.citrix.com/XenServer/6.0.0/1.0/en_gb/api/?c=VLAN
#
def create_vlan(config = {}, extra_params = {})
pif_ref = extra_params.delete(:pif_ref)
tag = config.delete(:tag)
network_ref = extra_params.delete(:network_ref)
@connection.request({ :parser => Fog::Parsers::XenServer::Base.new, :method => 'VLAN.create' },
pif_ref, tag.to_s, network_ref)
extra_params[:pif_ref], config[:tag].to_s, extra_params[:network_ref])
end
end
end
Expand Down

0 comments on commit ee3ecba

Please sign in to comment.