Sha256: 699f9819f5401fdfc2c01e1fd8a0289e88d774edad7a8024a506b0b242e80baa

Contents?: true

Size: 1.57 KB

Versions: 16

Compression:

Stored size: 1.57 KB

Contents

# frozen_string_literal: true

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

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

        def all(options = {})
          data = Fog::JSON.decode(service.list_servers(options).body)['Instances']['Instance']
          load(data)
        end

        # Creates a new server and populates ssh keys
        # @return [Fog::Compute::OpenStack::Server]
        # @raise [Fog::Compute::OpenStack::NotFound] - HTTP 404
        # @raise [Fog::Compute::OpenStack::BadRequest] - HTTP 400
        # @raise [Fog::Compute::OpenStack::InternalServerError] - HTTP 500
        # @raise [Fog::Compute::OpenStack::ServiceError]
        # @example
        #   service.servers.bootstrap :name => 'bootstrap-server',
        #                             :flavor_ref => service.flavors.first.id,
        #                             :image_ref => service.images.find {|img| img.name =~ /Ubuntu/}.id,
        #                             :public_key_path => '~/.ssh/fog_rsa.pub',
        #                             :private_key_path => '~/.ssh/fog_rsa'
        #
        #        def bootstrap(new_attributes = {})
        #          server = create(new_attributes)
        #          server.wait_for { ready? }
        #          server.setup(:password => server.password)
        #          server
        #        end

        def get(server_id)
          self.class.new(service: service).all(instanceId: server_id)[0] if server_id
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
fog-aliyun-0.4.0 lib/fog/aliyun/models/compute/servers.rb
fog-aliyun-0.3.19 lib/fog/aliyun/models/compute/servers.rb
fog-aliyun-0.3.18 lib/fog/aliyun/models/compute/servers.rb
fog-aliyun-0.3.17 lib/fog/aliyun/models/compute/servers.rb
fog-aliyun-0.3.16 lib/fog/aliyun/models/compute/servers.rb
fog-aliyun-0.3.15 lib/fog/aliyun/models/compute/servers.rb
fog-aliyun-0.3.13 lib/fog/aliyun/models/compute/servers.rb
fog-aliyun-0.3.12 lib/fog/aliyun/models/compute/servers.rb
fog-aliyun-0.3.11 lib/fog/aliyun/models/compute/servers.rb
fog-aliyun-0.3.10 lib/fog/aliyun/models/compute/servers.rb
fog-aliyun-0.3.9 lib/fog/aliyun/models/compute/servers.rb
fog-aliyun-0.3.8 lib/fog/aliyun/models/compute/servers.rb
fog-aliyun-0.3.7 lib/fog/aliyun/models/compute/servers.rb
fog-aliyun-0.3.6 lib/fog/aliyun/models/compute/servers.rb
fog-aliyun-0.3.5 lib/fog/aliyun/models/compute/servers.rb
fog-aliyun-0.3.4 lib/fog/aliyun/models/compute/servers.rb