From d49b10b1dc1f195e7e8248e50ed352b7e570e3f4 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Wed, 2 Oct 2013 09:21:25 -0400 Subject: [PATCH] Fix orchestration request status codes. Make the OpenStack Orchestration return codes match what actually gets returned from Heat. --- lib/fog/openstack/requests/orchestration/create_stack.rb | 7 +++++-- lib/fog/openstack/requests/orchestration/delete_stack.rb | 3 ++- lib/fog/openstack/requests/orchestration/list_stacks.rb | 1 + lib/fog/openstack/requests/orchestration/update_stack.rb | 1 + tests/openstack/requests/orchestration/stack_tests.rb | 7 ++++++- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/fog/openstack/requests/orchestration/create_stack.rb b/lib/fog/openstack/requests/orchestration/create_stack.rb index e19d35c79..3deca4bac 100644 --- a/lib/fog/openstack/requests/orchestration/create_stack.rb +++ b/lib/fog/openstack/requests/orchestration/create_stack.rb @@ -22,6 +22,7 @@ module Fog }.merge(options) request( + :expects => 201, :path => 'stacks', :method => 'POST', :body => MultiJson.encode(params) @@ -45,8 +46,10 @@ module Fog } response = Excon::Response.new - response.status = 202 - response.body = {} + response.status = 201 + response.body = { + 'id' => stack_id, + 'links'=>[{"href"=>"http://localhost:8004/v1/fake_tenant_id/stacks/#{stack_name}/#{stack_id}", "rel"=>"self"}]} response end end diff --git a/lib/fog/openstack/requests/orchestration/delete_stack.rb b/lib/fog/openstack/requests/orchestration/delete_stack.rb index ba179fb4a..6b14cb45b 100644 --- a/lib/fog/openstack/requests/orchestration/delete_stack.rb +++ b/lib/fog/openstack/requests/orchestration/delete_stack.rb @@ -14,6 +14,7 @@ module Fog def delete_stack(stack_name, stack_id) request( + :expects => 204, :path => "stacks/#{stack_name}/#{stack_id}", :method => 'DELETE' ) @@ -26,7 +27,7 @@ module Fog self.data[:stacks].delete(stack_id) response = Excon::Response.new - response.status = 202 + response.status = 204 response.body = {} response end diff --git a/lib/fog/openstack/requests/orchestration/list_stacks.rb b/lib/fog/openstack/requests/orchestration/list_stacks.rb index ab083285b..eee9056e4 100644 --- a/lib/fog/openstack/requests/orchestration/list_stacks.rb +++ b/lib/fog/openstack/requests/orchestration/list_stacks.rb @@ -25,6 +25,7 @@ module Fog def list_stacks(options = {}) request( + :expects => 200, :path => 'stacks', :method => 'GET', :query => options diff --git a/lib/fog/openstack/requests/orchestration/update_stack.rb b/lib/fog/openstack/requests/orchestration/update_stack.rb index 222ca388f..637a1ddd2 100644 --- a/lib/fog/openstack/requests/orchestration/update_stack.rb +++ b/lib/fog/openstack/requests/orchestration/update_stack.rb @@ -20,6 +20,7 @@ module Fog }.merge(options) request( + :expects => 202, :path => 'stacks', :method => 'PUT', :body => MultiJson.encode(params) diff --git a/tests/openstack/requests/orchestration/stack_tests.rb b/tests/openstack/requests/orchestration/stack_tests.rb index 0e6530e86..73535c7f5 100644 --- a/tests/openstack/requests/orchestration/stack_tests.rb +++ b/tests/openstack/requests/orchestration/stack_tests.rb @@ -10,8 +10,13 @@ Shindo.tests('Fog::Orchestration[:openstack] | stack requests', ['openstack']) d 'updated_time' => Time } + @create_format = { + 'id' => String, + 'links' => Array, + } + tests('success') do - tests('#create_stack("teststack")').formats({}) do + tests('#create_stack("teststack")').formats(@create_format) do Fog::Orchestration[:openstack].create_stack("teststack").body end