mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
* Added custom_templates and templates methods to Host model
This commit is contained in:
parent
ae6e59849f
commit
ba8313f099
2 changed files with 32 additions and 0 deletions
|
@ -23,6 +23,16 @@ module Fog
|
|||
attribute :__pifs, :aliases => :PIFs
|
||||
attribute :__resident_vms, :aliases => :resident_VMs
|
||||
|
||||
def templates
|
||||
connection.servers.all(:include_templates => true).delete_if { |s| !s.is_a_template }
|
||||
end
|
||||
|
||||
def custom_templates
|
||||
connection.servers.all(:include_custom_templates => true).delete_if do |s|
|
||||
!s.is_a_template
|
||||
end
|
||||
end
|
||||
|
||||
def pifs
|
||||
__pifs.collect { |pif| connection.pifs.get pif }
|
||||
end
|
||||
|
|
|
@ -64,4 +64,26 @@ Shindo.tests('Fog::Compute[:xenserver] | host model', ['xenserver']) do
|
|||
|
||||
end
|
||||
|
||||
tests("The host template list should") do
|
||||
test("include a #{test_template_name} template in custom_templates") do
|
||||
found = false
|
||||
host.custom_templates.each do |s|
|
||||
found = (s.name == test_template_name)
|
||||
end
|
||||
found
|
||||
end
|
||||
test("include only one custom template") { host.custom_templates.size == 1 }
|
||||
tests("not include built-in templates in custom_templates") do
|
||||
host.custom_templates.each do |s|
|
||||
test("#{s.name} is NOT a built-in template") {s.allowed_operations.include?('destroy') }
|
||||
end
|
||||
end
|
||||
test("include more than one built-in templates") { host.templates.size >= 1 }
|
||||
tests("not include real servers") do
|
||||
host.templates.each do |s|
|
||||
test("#{s.name} is not a real server") { s.is_a_template }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue