Class: Fog::Orchestration::OpenStack::Templates

Inherits:
Fog::OpenStack::Collection show all
Defined in:
lib/fog/orchestration/openstack/models/templates.rb

Instance Attribute Summary

Attributes inherited from Fog::OpenStack::Collection

#response

Instance Method Summary collapse

Methods inherited from Fog::OpenStack::Collection

#all, #destroy, #find_by_id, #load_response, #summary

Instance Method Details

#get(obj) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fog/orchestration/openstack/models/templates.rb', line 10

def get(obj)
  data = if obj.kind_of?(Stack)
           service.get_stack_template(obj).body
         else
           service.show_resource_template(obj.resource_name).body
         end

  if data.key?('AWSTemplateFormatVersion')
    data['content'] = data.to_json
    data['format'] = 'CFN'
    data['template_version'] = data.delete('AWSTemplateFormatVersion')
    data['description'] = data.delete('Description')
    data['parameter'] = data.delete('Parameters')
    data['resources'] = data.delete('Resources')
  else
    data['content'] = data.to_yaml
    data['format'] = 'HOT'
    data['template_version'] = data.delete('heat_template_version')
  end

  new(data)
rescue Fog::Orchestration::OpenStack::NotFound
  nil
end

#validate(options = {}) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/fog/orchestration/openstack/models/templates.rb', line 35

def validate(options = {})
  data = service.validate_template(options).body
  temp = new
  temp.parameters  = data['Parameters']
  temp.description = data['Description']
  temp
end