Class: Fog::Compute::SakuraCloud::Servers

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

Instance Method Summary collapse

Instance Method Details

#allObject



11
12
13
# File 'lib/fog/sakuracloud/models/compute/servers.rb', line 11

def all
  load service.list_servers.body['Servers']
end

#create(options = {}) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fog/sakuracloud/models/compute/servers.rb', line 21

def create(options = {})
  user = options[:user] || 'root'
  Fog::Logger.warning("Create Server")
  data = service.create_server(Fog::UUID.uuid, options[:serverplan]).body["Server"]
  server = service.servers.new
  server.merge_attributes(data)

  if options[:volume]
    disk = create_and_attach_volume(server, options)
    server.reload
  end
  server.boot if options[:boot]
  server
end

#get(id) ⇒ Object



15
16
17
18
19
# File 'lib/fog/sakuracloud/models/compute/servers.rb', line 15

def get(id)
  all.find { |f| f.id == id }
rescue Fog::Errors::NotFound
  nil
end