add RAW tests
This commit is contained in:
parent
c7dcc272c3
commit
7d64ddcbce
|
@ -21,6 +21,9 @@
|
||||||
# OS=[
|
# OS=[
|
||||||
# ARCH="x86_64",
|
# ARCH="x86_64",
|
||||||
# BOOT="network,hd" ]
|
# BOOT="network,hd" ]
|
||||||
|
# RAW=[
|
||||||
|
# DATA="<cpu match='exact'><model fallback='allow'>core2duo</model></cpu>",
|
||||||
|
# TYPE="kvm" ]
|
||||||
|
|
||||||
|
|
||||||
module Fog
|
module Fog
|
||||||
|
@ -37,7 +40,7 @@ module Fog
|
||||||
templates.info!(-2, filter[:id], filter[:id])
|
templates.info!(-2, filter[:id], filter[:id])
|
||||||
end # if filter[:id].nil?
|
end # if filter[:id].nil?
|
||||||
|
|
||||||
templates = templates.map do |t|
|
templates = templates.map do |t|
|
||||||
# filtering by name
|
# filtering by name
|
||||||
# done here, because OpenNebula:TemplatePool does not support something like .delete_if
|
# done here, because OpenNebula:TemplatePool does not support something like .delete_if
|
||||||
if filter[:name] && filter[:name].is_a?(String) && !filter[:name].empty?
|
if filter[:name] && filter[:name].is_a?(String) && !filter[:name].empty?
|
||||||
|
@ -51,8 +54,8 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
h = Hash[
|
h = Hash[
|
||||||
:id => t.to_hash["VMTEMPLATE"]["ID"],
|
:id => t.to_hash["VMTEMPLATE"]["ID"],
|
||||||
:name => t.to_hash["VMTEMPLATE"]["NAME"],
|
:name => t.to_hash["VMTEMPLATE"]["NAME"],
|
||||||
:content => t.template_str,
|
:content => t.template_str,
|
||||||
:USER_VARIABLES => "" # Default if not set in template
|
:USER_VARIABLES => "" # Default if not set in template
|
||||||
]
|
]
|
||||||
|
@ -67,7 +70,7 @@ module Fog
|
||||||
vnet = networks.get(n["NETWORK_ID"].to_s)
|
vnet = networks.get(n["NETWORK_ID"].to_s)
|
||||||
elsif n["NETWORK"]
|
elsif n["NETWORK"]
|
||||||
vnet = networks.get_by_name(n["NETWORK"].to_s)
|
vnet = networks.get_by_name(n["NETWORK"].to_s)
|
||||||
else
|
else
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
h["NIC"] << interfaces.new({ :vnet => vnet, :model => n["MODEL"] || "virtio" })
|
h["NIC"] << interfaces.new({ :vnet => vnet, :model => n["MODEL"] || "virtio" })
|
||||||
|
@ -87,15 +90,15 @@ module Fog
|
||||||
else
|
else
|
||||||
# should i break?
|
# should i break?
|
||||||
end
|
end
|
||||||
|
|
||||||
# every key should be lowercase
|
# every key should be lowercase
|
||||||
ret_hash = {}
|
ret_hash = {}
|
||||||
h.each_pair do |k,v|
|
h.each_pair do |k,v|
|
||||||
ret_hash.merge!({k.downcase => v})
|
ret_hash.merge!({k.downcase => v})
|
||||||
end
|
end
|
||||||
ret_hash
|
ret_hash
|
||||||
end
|
end
|
||||||
|
|
||||||
templates.delete nil
|
templates.delete nil
|
||||||
raise Fog::Compute::OpenNebula::NotFound, "Flavor/Template not found" if templates.empty?
|
raise Fog::Compute::OpenNebula::NotFound, "Flavor/Template not found" if templates.empty?
|
||||||
templates
|
templates
|
||||||
|
@ -107,7 +110,7 @@ module Fog
|
||||||
nic1 = Mock_nic.new
|
nic1 = Mock_nic.new
|
||||||
nic1.vnet = networks.first
|
nic1.vnet = networks.first
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
:content => %Q{
|
:content => %Q{
|
||||||
NAME = mock-vm
|
NAME = mock-vm
|
||||||
|
@ -131,14 +134,14 @@ module Fog
|
||||||
'ARCH' => 'x86_64'
|
'ARCH' => 'x86_64'
|
||||||
},
|
},
|
||||||
:graphics => {},
|
:graphics => {},
|
||||||
:raw => {},
|
:raw => %|["DATA"=>"<cpu match='exact'><model fallback='allow'>core2duo</model></cpu>", "TYPE"=>"kvm"]|,
|
||||||
:context => {},
|
:context => {},
|
||||||
:user_variables => {}
|
:user_variables => {}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
class Mock_nic
|
class Mock_nic
|
||||||
attr_accessor :vnet
|
attr_accessor :vnet
|
||||||
|
|
||||||
def id
|
def id
|
||||||
|
|
|
@ -9,7 +9,6 @@ Shindo.tests('Fog::Compute[:opennebula] | flavor model', ['opennebula']) do
|
||||||
end
|
end
|
||||||
tests('have attributes') do
|
tests('have attributes') do
|
||||||
model_attribute_hash = flavor.attributes
|
model_attribute_hash = flavor.attributes
|
||||||
attributes =
|
|
||||||
tests("The flavor model should respond to") do
|
tests("The flavor model should respond to") do
|
||||||
[:name, :id, :to_label, :to_s, :get_cpu, :get_vcpu, :get_memory, :get_raw, :get_disk, :get_os,
|
[:name, :id, :to_label, :to_s, :get_cpu, :get_vcpu, :get_memory, :get_raw, :get_disk, :get_os,
|
||||||
:get_graphics, :get_nic, :get_sched_ds_requirements, :get_sched_ds_rank, :get_sched_requirements,
|
:get_graphics, :get_nic, :get_sched_ds_requirements, :get_sched_ds_rank, :get_sched_requirements,
|
||||||
|
@ -31,6 +30,7 @@ Shindo.tests('Fog::Compute[:opennebula] | flavor model', ['opennebula']) do
|
||||||
test('have a 666 MB memory') { flavor.get_memory == "MEMORY=666\n" }
|
test('have a 666 MB memory') { flavor.get_memory == "MEMORY=666\n" }
|
||||||
test('have a 666 CPUs') { flavor.get_vcpu == "VCPU=666\n" }
|
test('have a 666 CPUs') { flavor.get_vcpu == "VCPU=666\n" }
|
||||||
|
|
||||||
|
test('raw parsed properly') { flavor.get_raw == %|RAW=["DATA"="<cpu match='exact'><model fallback='allow'>core2duo</model></cpu>", "TYPE"="kvm"]\n| }
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue