Class: Fog::Compute::VirtualBox::Server
- Inherits:
-
Model
- Object
- Model
- Fog::Compute::VirtualBox::Server
show all
- Defined in:
- lib/fog/compute/models/virtual_box/server.rb
Instance Attribute Summary collapse
Attributes inherited from Model
#collection, #connection
Instance Method Summary
collapse
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
Constructor Details
#initialize(attributes = {}) ⇒ Server
Returns a new instance of Server.
74
75
76
77
78
79
|
# File 'lib/fog/compute/models/virtual_box/server.rb', line 74
def initialize(attributes={})
self.memory_size = 256
self.rtc_use_utc = true
self.vram_size = 8
super
end
|
Instance Attribute Details
#private_key ⇒ Object
110
111
112
|
# File 'lib/fog/compute/models/virtual_box/server.rb', line 110
def private_key
@private_key ||= private_key_path && File.read(private_key_path)
end
|
#private_key_path ⇒ Object
105
106
107
108
|
# File 'lib/fog/compute/models/virtual_box/server.rb', line 105
def private_key_path
@private_key_path ||= Fog.credentials[:private_key_path]
@private_key_path &&= File.expand_path(@private_key_path)
end
|
#public_key ⇒ Object
123
124
125
|
# File 'lib/fog/compute/models/virtual_box/server.rb', line 123
def public_key
@public_key ||= public_key_path && File.read(public_key_path)
end
|
#public_key_path ⇒ Object
118
119
120
121
|
# File 'lib/fog/compute/models/virtual_box/server.rb', line 118
def public_key_path
@public_key_path ||= Fog.credentials[:public_key_path]
@public_key_path &&= File.expand_path(@public_key_path)
end
|
#username ⇒ Object
207
208
209
|
# File 'lib/fog/compute/models/virtual_box/server.rb', line 207
def username
@username ||= 'root'
end
|
Instance Method Details
#destroy ⇒ Object
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/fog/compute/models/virtual_box/server.rb', line 81
def destroy
requires :name, :raw
unless raw.state == :powered_off
stop
wait_for { raw.session_state == :closed }
end
raw.unregister(:full)
config_file = connection.compose_machine_filename(name)
config_directory = config_file.split(File::SEPARATOR)[0...-1].join(File::SEPARATOR)
FileUtils.rm_rf(config_directory)
true
end
|
#network_adapters ⇒ Object
94
95
96
97
98
99
|
# File 'lib/fog/compute/models/virtual_box/server.rb', line 94
def network_adapters
Fog::Compute::VirtualBox::NetworkAdapters.new(
:connection => connection,
:machine => self
)
end
|
#private_ip_address ⇒ Object
101
102
103
|
# File 'lib/fog/compute/models/virtual_box/server.rb', line 101
def private_ip_address
nil
end
|
#public_ip_address ⇒ Object
114
115
116
|
# File 'lib/fog/compute/models/virtual_box/server.rb', line 114
def public_ip_address
nil
end
|
#ready? ⇒ Boolean
127
128
129
|
# File 'lib/fog/compute/models/virtual_box/server.rb', line 127
def ready?
status == :running
end
|
#reboot ⇒ Object
131
132
133
134
135
|
# File 'lib/fog/compute/models/virtual_box/server.rb', line 131
def reboot
requires :raw
session.console.reset
true
end
|
#save ⇒ Object
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
# File 'lib/fog/compute/models/virtual_box/server.rb', line 137
def save
unless identity
requires :name, :os
self.raw = connection.create_machine(nil, name, os)
connection.register_machine(raw)
with_session do |session|
for attribute in [:description, :memory_size, :rtc_use_utc, :vram_size]
session.machine.send(:"#{attribute}=", attributes[attribute])
end
session.machine.save_settings
end
true
else
raise Fog::Errors::Error.new('Updating an existing server is not yet implemented. Contributions welcome!')
end
end
|
#scp(local_path, remote_path, upload_options = {}) ⇒ Object
154
155
156
157
158
159
160
161
|
# File 'lib/fog/compute/models/virtual_box/server.rb', line 154
def scp(local_path, remote_path, upload_options = {})
raise 'Not Implemented'
end
|
#setup(credentials = {}) ⇒ Object
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
# File 'lib/fog/compute/models/virtual_box/server.rb', line 163
def setup(credentials = {})
raise 'Not Implemented'
end
|
#ssh(commands) ⇒ Object
178
179
180
181
182
183
184
185
|
# File 'lib/fog/compute/models/virtual_box/server.rb', line 178
def ssh(commands)
raise 'Not Implemented'
end
|
#start(type = 'headless') ⇒ Object
187
188
189
190
191
192
|
# File 'lib/fog/compute/models/virtual_box/server.rb', line 187
def start(type = 'headless')
requires :raw
raw.launch_vm_process(session, type, '').wait
true
end
|
#stop ⇒ Object
194
195
196
197
198
|
# File 'lib/fog/compute/models/virtual_box/server.rb', line 194
def stop
requires :raw
session.console.power_down.wait
true
end
|
#storage_controllers ⇒ Object
200
201
202
203
204
205
|
# File 'lib/fog/compute/models/virtual_box/server.rb', line 200
def storage_controllers
Fog::Compute::VirtualBox::StorageControllers.new(
:connection => connection,
:machine => self
)
end
|