Class: Fog::GoGrid::Compute::Server

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/compute/models/go_grid/server.rb

Instance Attribute Summary

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

Methods inherited from Model

#inspect, #reload, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #identity, #identity=, #merge_attributes, #new_record?, #requires

Constructor Details

#initialize(attributes = {}) ⇒ Server

Returns a new instance of Server.



21
22
23
# File 'lib/fog/compute/models/go_grid/server.rb', line 21

def initialize(attributes={})
  super
end

Instance Method Details

#destroyObject



25
26
27
28
29
# File 'lib/fog/compute/models/go_grid/server.rb', line 25

def destroy
  requires :id
  connection.grid_server_destroy(id)
  true
end

#imageObject



31
32
33
34
# File 'lib/fog/compute/models/go_grid/server.rb', line 31

def image
  requires :image_id
  connection.grid_image_get(image_id)
end

#ready?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/fog/compute/models/go_grid/server.rb', line 36

def ready?
  @state == 'On'
end

#saveObject

Raises:



40
41
42
43
44
45
46
47
48
49
# File 'lib/fog/compute/models/go_grid/server.rb', line 40

def save
  raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
  requires :name, :image_id, :ip, :memory
  options['isSandbox'] = sandbox if sandbox
  options['server.ram'] = memory
  options['image'] = image_id
  data = connection.grid_server_add(name, image, ip, options)
  merge_attributes(data.body)
  true
end