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



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

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

#create(options = {}) ⇒ Object



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

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



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

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