mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
c8b21b067d
Error message gems/fog-1.14.0/lib/fog/cloudstack/models/compute/servers.rb:26:in `get': undefined method `empty?' for nil:NilClass (NoMethodError)
36 lines
921 B
Ruby
36 lines
921 B
Ruby
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={})
|
|
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)
|
|
servers = service.list_virtual_machines('id' => server_id)["listvirtualmachinesresponse"]["virtualmachine"]
|
|
unless servers.nil? || servers.empty?
|
|
new(servers.first)
|
|
end
|
|
rescue Fog::Compute::Cloudstack::BadRequest
|
|
nil
|
|
end
|
|
end
|
|
|
|
end
|
|
end
|
|
end
|