Sha256: d8242fea76bbc207976ecf61fdbf47e7240b39f965f6eab6f2988afe1e83e638

Contents?: true

Size: 1.21 KB

Versions: 24

Compression:

Stored size: 1.21 KB

Contents

require 'fog/core/collection'
require 'fog/cloudstack/models/compute/server'

module Fog
  module Compute
    class Cloudstack
      class Servers < Fog::Collection
        model Fog::Compute::Cloudstack::Server

        def all(attributes={})
          # add project id if we have one
          response = service.list_virtual_machines(attributes)
          data = response["listvirtualmachinesresponse"]["virtualmachine"] || []
          load(data)
        end

        def bootstrap(new_attributes = {})
          server = create(new_attributes)
          server.wait_for { ready? }
          server
        end

        def get(server_id)
          attributes = {'id' => server_id}
          # add project id if we have one
          servers = service.list_virtual_machines(attributes)["listvirtualmachinesresponse"]["virtualmachine"]
          if servers.nil? || servers.empty?
            servers = service.list_virtual_machines('id' => server_id, 'projectid' => '-1')["listvirtualmachinesresponse"]["virtualmachine"]
          end
          unless servers.nil? || servers.empty?
            new(servers.first)
          end
        rescue Fog::Compute::Cloudstack::BadRequest
          nil
        end
      end
    end
  end
end

Version data entries

24 entries across 22 versions & 3 rubygems

Version Path
fog-2.1.0 lib/fog/cloudstack/models/compute/servers.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-1.42.1/lib/fog/cloudstack/models/compute/servers.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-1.42.1/lib/fog/cloudstack/models/compute/servers.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-1.42.1/lib/fog/cloudstack/models/compute/servers.rb
fog-1.42.1 lib/fog/cloudstack/models/compute/servers.rb
fog-2.0.0 lib/fog/cloudstack/models/compute/servers.rb
fog-1.42.0 lib/fog/cloudstack/models/compute/servers.rb
fog-1.41.0 lib/fog/cloudstack/models/compute/servers.rb
fog-1.40.0 lib/fog/cloudstack/models/compute/servers.rb
fog-1.39.0 lib/fog/cloudstack/models/compute/servers.rb
fog-1.38.0 lib/fog/cloudstack/models/compute/servers.rb
fog-1.37.0 lib/fog/cloudstack/models/compute/servers.rb
fog-1.36.0 lib/fog/cloudstack/models/compute/servers.rb
fog-1.35.0 lib/fog/cloudstack/models/compute/servers.rb
fog-2.0.0.pre.0 lib/fog/cloudstack/models/compute/servers.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/cloudstack/models/compute/servers.rb
fog-1.34.0 lib/fog/cloudstack/models/compute/servers.rb
fog-1.33.0 lib/fog/cloudstack/models/compute/servers.rb
fog-1.32.0 lib/fog/cloudstack/models/compute/servers.rb
fog-1.31.0 lib/fog/cloudstack/models/compute/servers.rb