Sha256: 8851dd44442731b516345f50071eab82d65a1d47ef2de12475881baadb309fce

Contents?: true

Size: 1.39 KB

Versions: 20

Compression:

Stored size: 1.39 KB

Contents

require 'fog/openstack/models/collection'
require 'fog/openstack/orchestration/models/template'

module Fog
  module OpenStack
    class Orchestration
      class Templates < Fog::OpenStack::Collection
        model Fog::OpenStack::Orchestration::Template

        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::OpenStack::Orchestration::NotFound
          nil
        end

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

Version data entries

20 entries across 20 versions & 3 rubygems

Version Path
fog-openstack-1.1.3 lib/fog/openstack/orchestration/models/templates.rb
fog-openstack-1.1.2 lib/fog/openstack/orchestration/models/templates.rb
fog-openstack-fork-99 lib/fog/openstack/orchestration/models/templates.rb
fog-openstack-1.1.0 lib/fog/openstack/orchestration/models/templates.rb
fog-openstack-1.1.0.pre lib/fog/openstack/orchestration/models/templates.rb
fog-openstack-apibank-1.0.102 lib/fog/openstack/orchestration/models/templates.rb
fog-openstack-1.0.11 lib/fog/openstack/orchestration/models/templates.rb
fog-openstack-apibank-1.0.101 lib/fog/openstack/orchestration/models/templates.rb
fog-openstack-1.0.10 lib/fog/openstack/orchestration/models/templates.rb
fog-openstack-1.0.9 lib/fog/openstack/orchestration/models/templates.rb
fog-openstack-1.0.8 lib/fog/openstack/orchestration/models/templates.rb
fog-openstack-1.0.7 lib/fog/openstack/orchestration/models/templates.rb
fog-openstack-1.0.6 lib/fog/openstack/orchestration/models/templates.rb
fog-openstack-1.0.5 lib/fog/openstack/orchestration/models/templates.rb
fog-openstack-1.0.4 lib/fog/openstack/orchestration/models/templates.rb
fog-openstack-1.0.3 lib/fog/openstack/orchestration/models/templates.rb
fog-openstack-1.0.2 lib/fog/openstack/orchestration/models/templates.rb
fog-openstack-1.0.1 lib/fog/openstack/orchestration/models/templates.rb
fog-openstack-1.0.0 lib/fog/openstack/orchestration/models/templates.rb
fog-openstack-0.3.1 lib/fog/openstack/orchestration/models/templates.rb