Class: Fog::Slicehost::Server
- Inherits:
-
Model
- Object
- Model
- Fog::Slicehost::Server
show all
- Defined in:
- lib/fog/slicehost/models/server.rb
Instance Attribute Summary
Attributes inherited from Model
#connection
Instance Method Summary
collapse
Methods inherited from Model
#collection, #inspect, #reload, #to_json, #wait_for
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
#_dump, #attributes, #identity, #identity=, #merge_attributes, #new_record?, #requires
Constructor Details
#initialize(attributes = {}) ⇒ Server
Returns a new instance of Server.
21
22
23
24
|
# File 'lib/fog/slicehost/models/server.rb', line 21
def initialize(attributes={})
@flavor_id ||= 1
super
end
|
Instance Method Details
#destroy ⇒ Object
26
27
28
29
30
|
# File 'lib/fog/slicehost/models/server.rb', line 26
def destroy
requires :id
connection.delete_slice(@id)
true
end
|
#flavor ⇒ Object
32
33
34
35
|
# File 'lib/fog/slicehost/models/server.rb', line 32
def flavor
requires :flavor_id
connection.flavors.get(@flavor_id)
end
|
#image ⇒ Object
37
38
39
40
|
# File 'lib/fog/slicehost/models/server.rb', line 37
def image
requires :image_id
connection.images.get(@image_id)
end
|
#ready? ⇒ Boolean
42
43
44
|
# File 'lib/fog/slicehost/models/server.rb', line 42
def ready?
@status == 'active'
end
|
#reboot(type = 'SOFT') ⇒ Object
46
47
48
49
50
|
# File 'lib/fog/slicehost/models/server.rb', line 46
def reboot(type = 'SOFT')
requires :id
connection.reboot_server(@id, type)
true
end
|
#save ⇒ Object
52
53
54
55
56
57
|
# File 'lib/fog/slicehost/models/server.rb', line 52
def save
requires :flavor_id, :image_id, :name
data = connection.create_slice(@flavor_id, @image_id, @name)
merge_attributes(data.body)
true
end
|