1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[opennebula] clean up and code simplification

This commit is contained in:
Achim Ledermüller 2014-06-05 10:27:34 +02:00
parent d4676d6e7c
commit 9031a00c92
3 changed files with 5 additions and 17 deletions

View file

@ -17,8 +17,7 @@ module Fog
end end
def description def description
return "" if @description.nil? attributes[:description] || ""
return @description
end end
def uuid=(str) def uuid=(str)
@ -29,13 +28,8 @@ module Fog
return self.id return self.id
end end
def vlan=(str)
@vlan=str
end
def vlan def vlan
return "" if @vlan.nil? attributes[:vlan] || ""
return @vlan
end end
def save def save

View file

@ -22,19 +22,13 @@ module Fog
attribute :flavor attribute :flavor
def save def save
#if persisted?
# service.update_vm(attributes)
#else
merge_attributes(service.vm_allocate(attributes)) merge_attributes(service.vm_allocate(attributes))
#end
#reload
end end
# only for integration in foreman # only for integration in foreman
# needed by formbuilder # needed by formbuilder
# should be handled by foreman and not from by fog # should be handled by foreman and not by fog
def vminterfaces def vminterfaces
#[] << Fog::Compute::OpenNebula::Interfaces.new
[] []
end end
@ -65,7 +59,7 @@ module Fog
if status == 4 if status == 4
service.vm_resume(id) service.vm_resume(id)
end end
return true true
end end
def stop def stop

View file

@ -8,7 +8,7 @@ Shindo.tests("Fog::Compute[:opennebula] | vm_create and destroy request", 'openn
tests("Allocate VM") do tests("Allocate VM") do
response = compute.vm_allocate({:name => 'fog-'+name_base.to_s, :flavor => f}) response = compute.vm_allocate({:name => 'fog-'+name_base.to_s, :flavor => f})
test("response should be a kind of Hash") { response.kind_of? Hash} test("response should be a kind of Hash") { response.kind_of? Hash}
test("id should be a one-id (interger)") { response['id'].is_a? Fixnum} test("id should be a one-id (Fixnum)") { response['id'].is_a? Fixnum}
end end
tests("Destroy VM") do tests("Destroy VM") do
compute.vm_destroy(response['id']) compute.vm_destroy(response['id'])