Class: Fog::Compute::Aliyun::Servers

Inherits:
Fog::Collection
  • Object
show all
Defined in:
lib/fog/aliyun/models/compute/servers.rb

Instance Method Summary collapse

Instance Method Details

#all(options = {}) ⇒ Object



12
13
14
15
# File 'lib/fog/aliyun/models/compute/servers.rb', line 12

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

#get(server_id) ⇒ Fog::Compute::OpenStack::Server

Creates a new server and populates ssh keys

Examples:

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

Returns:

  • (Fog::Compute::OpenStack::Server)

Raises:

  • (Fog::Compute::OpenStack::NotFound)
    • HTTP 404

  • (Fog::Compute::OpenStack::BadRequest)
    • HTTP 400

  • (Fog::Compute::OpenStack::InternalServerError)
    • HTTP 500

  • (Fog::Compute::OpenStack::ServiceError)


37
38
39
# File 'lib/fog/aliyun/models/compute/servers.rb', line 37

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