From 9031a00c922d006f19e768b709daa3efdcd35099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Achim=20Lederm=C3=BCller?= Date: Thu, 5 Jun 2014 10:27:34 +0200 Subject: [PATCH] [opennebula] clean up and code simplification --- lib/fog/opennebula/models/compute/network.rb | 10 ++-------- lib/fog/opennebula/models/compute/server.rb | 10 ++-------- tests/opennebula/requests/compute/vm_allocate_tests.rb | 2 +- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/lib/fog/opennebula/models/compute/network.rb b/lib/fog/opennebula/models/compute/network.rb index eb25b2b11..f591d1ede 100644 --- a/lib/fog/opennebula/models/compute/network.rb +++ b/lib/fog/opennebula/models/compute/network.rb @@ -17,8 +17,7 @@ module Fog end def description - return "" if @description.nil? - return @description + attributes[:description] || "" end def uuid=(str) @@ -29,13 +28,8 @@ module Fog return self.id end - def vlan=(str) - @vlan=str - end - def vlan - return "" if @vlan.nil? - return @vlan + attributes[:vlan] || "" end def save diff --git a/lib/fog/opennebula/models/compute/server.rb b/lib/fog/opennebula/models/compute/server.rb index 665e14569..82d2480ee 100644 --- a/lib/fog/opennebula/models/compute/server.rb +++ b/lib/fog/opennebula/models/compute/server.rb @@ -22,19 +22,13 @@ module Fog attribute :flavor def save - #if persisted? - # service.update_vm(attributes) - #else merge_attributes(service.vm_allocate(attributes)) - #end - #reload end # only for integration in foreman # needed by formbuilder - # should be handled by foreman and not from by fog + # should be handled by foreman and not by fog def vminterfaces - #[] << Fog::Compute::OpenNebula::Interfaces.new [] end @@ -65,7 +59,7 @@ module Fog if status == 4 service.vm_resume(id) end - return true + true end def stop diff --git a/tests/opennebula/requests/compute/vm_allocate_tests.rb b/tests/opennebula/requests/compute/vm_allocate_tests.rb index 11169f040..5e8a8d0b1 100644 --- a/tests/opennebula/requests/compute/vm_allocate_tests.rb +++ b/tests/opennebula/requests/compute/vm_allocate_tests.rb @@ -8,7 +8,7 @@ Shindo.tests("Fog::Compute[:opennebula] | vm_create and destroy request", 'openn tests("Allocate VM") do 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("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 tests("Destroy VM") do compute.vm_destroy(response['id'])