Class: VagrantPlugins::Openstack::HeatClient
- Inherits:
-
Object
- Object
- VagrantPlugins::Openstack::HeatClient
show all
- Includes:
- Singleton, Domain, HttpUtils
- Defined in:
- lib/vagrant-openstack-provider/client/heat.rb
Instance Method Summary
collapse
Methods included from HttpUtils
#delete, #get, #get_api_version_list, #post
#log_request, #log_response
Constructor Details
Returns a new instance of HeatClient.
15
16
17
18
|
# File 'lib/vagrant-openstack-provider/client/heat.rb', line 15
def initialize
@logger = Log4r::Logger.new('vagrant_openstack::glance')
@session = VagrantPlugins::Openstack.session
end
|
Instance Method Details
#create_stack(env, options) ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/vagrant-openstack-provider/client/heat.rb', line 20
def create_stack(env, options)
stack = {}.tap do |s|
s['stack_name'] = options[:name] if options[:name]
s['template'] = options[:template]
end
stack_res = post(env, "#{@session.endpoints[:orchestration]}/stacks", stack.to_json)
JSON.parse(stack_res)['stack']['id']
end
|
#delete_stack(env, stack_name, stack_id) ⇒ Object
36
37
38
39
40
|
# File 'lib/vagrant-openstack-provider/client/heat.rb', line 36
def delete_stack(env, stack_name, stack_id)
stack_exists do
delete(env, "#{@session.endpoints[:orchestration]}/stacks/#{stack_name}/#{stack_id}")
end
end
|
#get_stack_details(env, stack_name, stack_id) ⇒ Object
29
30
31
32
33
34
|
# File 'lib/vagrant-openstack-provider/client/heat.rb', line 29
def get_stack_details(env, stack_name, stack_id)
stack_exists do
server_details = get(env, "#{@session.endpoints[:orchestration]}/stacks/#{stack_name}/#{stack_id}")
JSON.parse(server_details)['stack']
end
end
|
#stack_exists ⇒ Object
42
43
44
45
46
47
|
# File 'lib/vagrant-openstack-provider/client/heat.rb', line 42
def stack_exists
return yield
rescue Errors::VagrantOpenstackError => e
raise Errors::StackNotFound if e.[:code] == 404
raise e
end
|