Skip to content

Commit

Permalink
Merge pull request fog#2212 from dprince/orchestration_fixes
Browse files Browse the repository at this point in the history
OpenStack Orchestration fixes
  • Loading branch information
dprince committed Oct 2, 2013
2 parents b490406 + d49b10b commit eb46930
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/fog/openstack/orchestration.rb
Expand Up @@ -163,7 +163,7 @@ def request(params)
end
end

if response.status == 200 && !response.body.empty?
if !response.body.empty? and response.get_header('Content-Type') =~ /application\/json/ then
response.body = Fog::JSON.decode(response.body)
end

Expand Down
7 changes: 5 additions & 2 deletions lib/fog/openstack/requests/orchestration/create_stack.rb
Expand Up @@ -22,6 +22,7 @@ def create_stack(stack_name, options = {})
}.merge(options)

request(
:expects => 201,
:path => 'stacks',
:method => 'POST',
:body => MultiJson.encode(params)
Expand All @@ -45,8 +46,10 @@ def create_stack(stack_name, options = {})
}

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
Expand Down
3 changes: 2 additions & 1 deletion lib/fog/openstack/requests/orchestration/delete_stack.rb
Expand Up @@ -14,6 +14,7 @@ class Real

def delete_stack(stack_name, stack_id)
request(
:expects => 204,
:path => "stacks/#{stack_name}/#{stack_id}",
:method => 'DELETE'
)
Expand All @@ -26,7 +27,7 @@ def delete_stack(stack_name, stack_id)
self.data[:stacks].delete(stack_id)

response = Excon::Response.new
response.status = 202
response.status = 204
response.body = {}
response
end
Expand Down
1 change: 1 addition & 0 deletions lib/fog/openstack/requests/orchestration/list_stacks.rb
Expand Up @@ -25,6 +25,7 @@ class Real

def list_stacks(options = {})
request(
:expects => 200,
:path => 'stacks',
:method => 'GET',
:query => options
Expand Down
1 change: 1 addition & 0 deletions lib/fog/openstack/requests/orchestration/update_stack.rb
Expand Up @@ -20,6 +20,7 @@ def update_stack(stack_name, options = {})
}.merge(options)

request(
:expects => 202,
:path => 'stacks',
:method => 'PUT',
:body => MultiJson.encode(params)
Expand Down
7 changes: 6 additions & 1 deletion tests/openstack/requests/orchestration/stack_tests.rb
Expand Up @@ -10,8 +10,13 @@
'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

Expand Down

0 comments on commit eb46930

Please sign in to comment.