Class: Fog::Bluebox::Compute::Server

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

Instance Attribute Summary collapse

Attributes inherited from Model

#connection

Instance Method Summary collapse

Methods inherited from Model

#collection, #initialize, #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

This class inherits a constructor from Fog::Model

Instance Attribute Details

#image_idObject

attribute :image_id



22
23
24
# File 'lib/fog/bluebox/models/compute/server.rb', line 22

def image_id
  @image_id
end

#passwordObject

Not reported by the API, but used at create time



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

def password
  @password
end

#ssh_keyObject

Not reported by the API, but used at create time



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

def ssh_key
  @ssh_key
end

#userObject

Not reported by the API, but used at create time



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

def user
  @user
end

Instance Method Details

#destroyObject



28
29
30
31
32
# File 'lib/fog/bluebox/models/compute/server.rb', line 28

def destroy
  requires :id
  connection.destroy_block(@id)
  true
end

#flavorObject



34
35
36
37
# File 'lib/fog/bluebox/models/compute/server.rb', line 34

def flavor
  requires :flavor_id
  connection.flavors.get(@flavor_id)
end

#imageObject



39
40
41
42
# File 'lib/fog/bluebox/models/compute/server.rb', line 39

def image
  requires :image_id
  connection.images.get(@image_id)
end

#ready?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/fog/bluebox/models/compute/server.rb', line 44

def ready?
  @status == 'running'
end

#reboot(type = 'SOFT') ⇒ Object



48
49
50
51
52
# File 'lib/fog/bluebox/models/compute/server.rb', line 48

def reboot(type = 'SOFT')
  requires :id
  connection.reboot_block(@id, type)
  true
end

#saveObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/fog/bluebox/models/compute/server.rb', line 54

def save
  requires :flavor_id, :image_id
  options = if !@password && !@ssh_key
    raise(ArgumentError, "password or ssh_key is required for this operation")
  elsif @ssh_key
    {'ssh_public_key' => @ssh_key}
  elsif @password
    {'password' => @password}
  end
  if @user
    options['user'] = @user
  end
  data = connection.create_block(@flavor_id, @image_id, options)
  merge_attributes(data.body)
  true
end