def create_server( name_label, template = nil, networks = [], extra_args = {})
if !networks.kind_of? Array
raise "Invalid networks argument"
end
if template.kind_of? String
template_string = template
template = servers.templates.find { |s| s.uuid == template_string }
if template.nil?
template = servers.get get_vm_by_name(template_string)
end
end
if template.nil?
raise "Invalid template"
end
raise "Template #{template_string} does not exist" if template.allowed_operations.nil?
raise 'Clone Operation not Allowed' unless template.allowed_operations.include?('clone')
ref = clone_server name_label, template.reference
networks.each do |n|
create_vif ref, n.reference
end
if !extra_args[:auto_start] == false
@connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VM.provision'}, ref)
start_vm( ref )
end
ref
end