Sha256: 57dfe16cc3c69f34f7ddbcc88405c4a1a2902545f1637caa9b313b193104ebf6

Contents?: true

Size: 1.54 KB

Versions: 6

Compression:

Stored size: 1.54 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 = {})
          Fog::JSON.decode(service.list_servers(options).body)['Instances']['Instance']
        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

6 entries across 4 versions & 2 rubygems

Version Path
fog-aliyun-0.3.3 lib/fog/aliyun/models/compute/servers.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-aliyun-0.3.2/lib/fog/aliyun/models/compute/servers.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-aliyun-0.3.2/lib/fog/aliyun/models/compute/servers.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-aliyun-0.3.2/lib/fog/aliyun/models/compute/servers.rb
fog-aliyun-0.3.2 lib/fog/aliyun/models/compute/servers.rb
fog-aliyun-0.3.1 lib/fog/aliyun/models/compute/servers.rb