From 788568cc32035373b3d7d414702145416520cd9f Mon Sep 17 00:00:00 2001 From: Eugene Howe Date: Mon, 4 Feb 2013 13:25:34 -0500 Subject: [PATCH] [ecloud] fixed object returns in mock --- lib/fog/ecloud/models/compute/detached_disks.rb | 6 +----- lib/fog/ecloud/models/compute/internet_services.rb | 6 +----- lib/fog/ecloud/models/compute/nodes.rb | 6 +----- lib/fog/ecloud/models/compute/public_ips.rb | 6 +----- lib/fog/ecloud/models/compute/servers.rb | 8 ++------ lib/fog/ecloud/requests/compute/get_detached_disk.rb | 2 +- lib/fog/ecloud/requests/compute/get_internet_service.rb | 2 +- lib/fog/ecloud/requests/compute/get_node.rb | 2 +- lib/fog/ecloud/requests/compute/get_public_ip.rb | 2 +- lib/fog/ecloud/requests/compute/get_server.rb | 2 +- 10 files changed, 11 insertions(+), 31 deletions(-) diff --git a/lib/fog/ecloud/models/compute/detached_disks.rb b/lib/fog/ecloud/models/compute/detached_disks.rb index 294be4f3f..b5eec82aa 100644 --- a/lib/fog/ecloud/models/compute/detached_disks.rb +++ b/lib/fog/ecloud/models/compute/detached_disks.rb @@ -17,11 +17,7 @@ module Fog def get(uri) data = service.get_detached_disk(uri).body - if data == "" - new({}) - else - new(data) - end + new(data) rescue Fog::Errors::NotFound nil end diff --git a/lib/fog/ecloud/models/compute/internet_services.rb b/lib/fog/ecloud/models/compute/internet_services.rb index 59591511a..3c0e14e9a 100644 --- a/lib/fog/ecloud/models/compute/internet_services.rb +++ b/lib/fog/ecloud/models/compute/internet_services.rb @@ -20,11 +20,7 @@ module Fog def get(uri) data = service.get_internet_service(uri).body - if data == "" - new({}) - else - new(data) - end + new(data) rescue Fog::Errors::NotFound nil end diff --git a/lib/fog/ecloud/models/compute/nodes.rb b/lib/fog/ecloud/models/compute/nodes.rb index 9e2dc20bd..9c9000304 100644 --- a/lib/fog/ecloud/models/compute/nodes.rb +++ b/lib/fog/ecloud/models/compute/nodes.rb @@ -20,11 +20,7 @@ module Fog def get(uri) data = service.get_node(uri).body - if data == "" - new({}) - else - new(data) - end + new(data) rescue Fog::Errors::NotFound nil end diff --git a/lib/fog/ecloud/models/compute/public_ips.rb b/lib/fog/ecloud/models/compute/public_ips.rb index 4c6e79037..8bc262c36 100644 --- a/lib/fog/ecloud/models/compute/public_ips.rb +++ b/lib/fog/ecloud/models/compute/public_ips.rb @@ -17,11 +17,7 @@ module Fog def get(uri) data = service.get_public_ip(uri).body - if data == "" - new({}) - else - new(data) - end + new(data) rescue Fog::Errors::NotFound nil end diff --git a/lib/fog/ecloud/models/compute/servers.rb b/lib/fog/ecloud/models/compute/servers.rb index dbf08f70d..f31041cf3 100644 --- a/lib/fog/ecloud/models/compute/servers.rb +++ b/lib/fog/ecloud/models/compute/servers.rb @@ -23,12 +23,8 @@ module Fog def get(uri) data = service.get_server(uri).body - if data == "" - new({}) - else - new(data) - end - rescue Excon::Errors::NotFound + new(data) + rescue Fog::Errors::NotFound nil end diff --git a/lib/fog/ecloud/requests/compute/get_detached_disk.rb b/lib/fog/ecloud/requests/compute/get_detached_disk.rb index a31956faa..8bdceefda 100644 --- a/lib/fog/ecloud/requests/compute/get_detached_disk.rb +++ b/lib/fog/ecloud/requests/compute/get_detached_disk.rb @@ -12,7 +12,7 @@ module Fog if detached_disk response(:body => Fog::Ecloud.slice(detached_disk, :id, :compute_pool_id)) - else response(:status => 404) # ? + else raise Fog::Errors::NotFound end end end diff --git a/lib/fog/ecloud/requests/compute/get_internet_service.rb b/lib/fog/ecloud/requests/compute/get_internet_service.rb index 97a8200b3..68397a14a 100644 --- a/lib/fog/ecloud/requests/compute/get_internet_service.rb +++ b/lib/fog/ecloud/requests/compute/get_internet_service.rb @@ -14,7 +14,7 @@ module Fog if internet_service response(:body => Fog::Ecloud.slice(internet_service, :id, :public_ip)) - else response(:status => 404) # ? + else raise Fog::Errors::NotFound end end end diff --git a/lib/fog/ecloud/requests/compute/get_node.rb b/lib/fog/ecloud/requests/compute/get_node.rb index b1bb78226..c8ac82fb9 100644 --- a/lib/fog/ecloud/requests/compute/get_node.rb +++ b/lib/fog/ecloud/requests/compute/get_node.rb @@ -13,7 +13,7 @@ module Fog if node_service response(:body => Fog::Ecloud.slice(node_service, :id, :internet_service_id)) - else response(:status => 404) # ? + else raise Fog::Errors::NotFound end end end diff --git a/lib/fog/ecloud/requests/compute/get_public_ip.rb b/lib/fog/ecloud/requests/compute/get_public_ip.rb index 6699bb9d2..53af29542 100644 --- a/lib/fog/ecloud/requests/compute/get_public_ip.rb +++ b/lib/fog/ecloud/requests/compute/get_public_ip.rb @@ -12,7 +12,7 @@ module Fog if public_ip response(:body => Fog::Ecloud.slice(public_ip, :id, :environment_id)) - else response(:status => 404) # ? + else raise Fog::Errors::NotFound end end end diff --git a/lib/fog/ecloud/requests/compute/get_server.rb b/lib/fog/ecloud/requests/compute/get_server.rb index 22e4d3de6..e21579a01 100644 --- a/lib/fog/ecloud/requests/compute/get_server.rb +++ b/lib/fog/ecloud/requests/compute/get_server.rb @@ -13,7 +13,7 @@ module Fog server = self.data[:servers][server_id] if server response(:body => Fog::Ecloud.slice(server, :id, :compute_pool_id)) - else response(:status => 404) # ? + else raise Fog::Errors::NotFound end end end