Class: Fog::Compute::Brightbox::Server
- Inherits:
-
Server
show all
- Defined in:
- lib/fog/brightbox/models/compute/server.rb
Instance Attribute Summary
Attributes inherited from Model
#collection, #connection
Instance Method Summary
collapse
Methods inherited from Server
#scp, #ssh
Methods inherited from Model
#inspect, #reload, #to_json, #wait_for
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one
Constructor Details
#initialize(attributes = {}) ⇒ Server
Returns a new instance of Server.
36
37
38
39
|
# File 'lib/fog/brightbox/models/compute/server.rb', line 36
def initialize(attributes={})
self.image_id ||= 'img-2ab98' super
end
|
Instance Method Details
#activate_console ⇒ Object
96
97
98
99
100
|
# File 'lib/fog/brightbox/models/compute/server.rb', line 96
def activate_console
requires :identity
response = connection.activate_console_server(identity)
[response["console_url"], response["console_token"], response["console_token_expires"]]
end
|
#destroy ⇒ Object
68
69
70
71
72
|
# File 'lib/fog/brightbox/models/compute/server.rb', line 68
def destroy
requires :identity
connection.destroy_server(identity)
true
end
|
#flavor ⇒ Object
74
75
76
77
|
# File 'lib/fog/brightbox/models/compute/server.rb', line 74
def flavor
requires :flavor_id
connection.flavors.get(flavor_id)
end
|
#image ⇒ Object
79
80
81
82
|
# File 'lib/fog/brightbox/models/compute/server.rb', line 79
def image
requires :image_id
connection.images.get(image_id)
end
|
#private_ip_address ⇒ Object
84
85
86
|
# File 'lib/fog/brightbox/models/compute/server.rb', line 84
def private_ip_address
interfaces.first
end
|
#public_ip_address ⇒ Object
88
89
90
|
# File 'lib/fog/brightbox/models/compute/server.rb', line 88
def public_ip_address
cloud_ips.first
end
|
#ready? ⇒ Boolean
92
93
94
|
# File 'lib/fog/brightbox/models/compute/server.rb', line 92
def ready?
self.state == 'active'
end
|
#reboot ⇒ Object
46
47
48
|
# File 'lib/fog/brightbox/models/compute/server.rb', line 46
def reboot
false
end
|
#save ⇒ Object
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
# File 'lib/fog/brightbox/models/compute/server.rb', line 102
def save
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
requires :image_id
options = {
:image => image_id,
:name => name,
:zone => zone_id,
:user_data => user_data
}.delete_if {|k,v| v.nil? || v == "" }
unless flavor_id.nil? || flavor_id == ""
options.merge!(:server_type => flavor_id)
end
data = connection.create_server(options)
merge_attributes(data)
true
end
|
#shutdown ⇒ Object
62
63
64
65
66
|
# File 'lib/fog/brightbox/models/compute/server.rb', line 62
def shutdown
requires :identity
connection.shutdown_server(identity)
true
end
|
#snapshot ⇒ Object
41
42
43
44
|
# File 'lib/fog/brightbox/models/compute/server.rb', line 41
def snapshot
requires :identity
connection.snapshot_server(identity)
end
|
#start ⇒ Object
50
51
52
53
54
|
# File 'lib/fog/brightbox/models/compute/server.rb', line 50
def start
requires :identity
connection.start_server(identity)
true
end
|
#stop ⇒ Object
56
57
58
59
60
|
# File 'lib/fog/brightbox/models/compute/server.rb', line 56
def stop
requires :identity
connection.stop_server(identity)
true
end
|