Class: Fog::Bluebox::Server

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/bluebox/models/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



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

def image_id
  @image_id
end

#passwordObject

Not reported by the API, but used at create time



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

def password
  @password
end

#ssh_keyObject

Not reported by the API, but used at create time



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

def ssh_key
  @ssh_key
end

#userObject

Not reported by the API, but used at create time



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

def user
  @user
end

Instance Method Details

#destroyObject



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

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

#flavorObject



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

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

#imageObject



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

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

#ready?Boolean

Returns:

  • (Boolean)


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

def ready?
  @status == 'running'
end

#reboot(type = 'SOFT') ⇒ Object



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

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

#saveObject



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

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_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