Skip to content

Commit de574af

Browse files
authored
Merge pull request #505 from andyvesel/stack_find_in_nested
Update Orchestration Stack find by ID method
2 parents c51856a + 4130c69 commit de574af

3 files changed

Lines changed: 31 additions & 3 deletions

File tree

lib/fog/openstack/orchestration.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class Orchestration < Fog::Service
4747
request :show_resource_metadata
4848
request :show_resource_schema
4949
request :show_resource_template
50+
request :show_stack
5051
request :show_stack_details
5152
request :update_stack
5253
request :patch_stack

lib/fog/openstack/orchestration/models/stacks.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ def summary(options = {})
2020
load_response(data, 'stacks')
2121
end
2222

23-
# Deprecated
2423
def find_by_id(id)
25-
Fog::Logger.deprecation("#find_by_id(id) is deprecated, use #get(name, id) instead [light_black](#{caller.first})[/]")
26-
find { |stack| stack.id == id }
24+
data = service.show_stack(id).body['stack']
25+
new(data)
26+
rescue Fog::OpenStack::Orchestration::NotFound
27+
nil
2728
end
2829

2930
def get(arg1, arg2 = nil)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module Fog
2+
module OpenStack
3+
class Orchestration
4+
class Real
5+
def show_stack(id)
6+
request(
7+
:method => 'GET',
8+
:path => "stacks/#{id}",
9+
:expects => 200
10+
)
11+
end
12+
end
13+
14+
class Mock
15+
def show_stack(_id)
16+
stack = data[:stack].values
17+
18+
Excon::Response.new(
19+
:body => {'stack' => stack},
20+
:status => 200
21+
)
22+
end
23+
end
24+
end
25+
end
26+
end

0 commit comments

Comments
 (0)