Sha256: a866618b0cd37e6d539aa11a01536e627dc382c50e8dbc91a3b5b83d01046299

Contents?: true

Size: 1.44 KB

Versions: 4

Compression:

Stored size: 1.44 KB

Contents

require 'fog/openstack/models/orchestration/stack'

module Fog
  module Orchestration
    class OpenStack
      class Stacks < Fog::Collection
        model Fog::Orchestration::OpenStack::Stack

        def all(options={})
          data = service.list_stack_data(options).body['stacks']
          load(data)
        end

        # Deprecated
        def find_by_id(id)
          Fog::Logger.deprecation("#find_by_id(id) is deprecated, use #get(name, id) instead [light_black](#{caller.first})[/]")
          self.find {|stack| stack.id == id}
        end

        def get(arg1, arg2 = nil)
          if arg2.nil?
            # Deprecated: get(id)
            Fog::Logger.deprecation("#get(id) is deprecated, use #get(name, id) instead [light_black](#{caller.first})[/]")
            return find_by_id(arg1)
          end

          # Normal use: get(name, id)
          name = arg1
          id = arg2
          data = service.show_stack_details(name, id).body['stack']
          new(data)
        rescue Fog::Compute::OpenStack::NotFound
          nil
        end

        def adopt(options={})
          service.create_stack(options)
        end

        def create(options={})
          service.create_stack(options).body['stack']
        end

        def preview(options={})
          data = service.preview_stack(options).body['stack']
          new(data)
        end

        def build_info
          service.build_info.body
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fog-1.31.0 lib/fog/openstack/models/orchestration/stacks.rb
fog-1.30.0 lib/fog/openstack/models/orchestration/stacks.rb
fog-1.29.0 lib/fog/openstack/models/orchestration/stacks.rb
fog-1.28.0 lib/fog/openstack/models/orchestration/stacks.rb