Class: Squall::VirtualMachine
- Inherits:
-
Base
- Object
- Base
- Squall::VirtualMachine
- Defined in:
- lib/squall/virtual_machine.rb
Overview
OnApp VirtualMachine
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary (collapse)
-
- (Object) build(id, options = {})
Build a virtual machine.
-
- (Object) change_owner(id, user_id)
Change the owner of a virtual machine.
-
- (Object) change_password(id, password)
Change the password.
-
- (Object) console(id)
Open a console for a virtual machine.
-
- (Object) create(options = {})
Create a new virtual machine.
-
- (Object) delete(id)
Delete a virtual machine.
-
- (Object) edit(id, options = {})
Edit a virtual machine.
-
- (Object) list
List all virtual machines.
-
- (Object) migrate(id, options = {})
Migrate a virtual machine to a new hypervisor.
-
- (Object) reboot(id, recovery = false)
Reboot a virtual machine.
-
- (Object) resize(id, options = {})
Resize a virtual machine's memory.
-
- (Object) segregate(id, target_vm_id)
Segregate a virtual machine from another virtual machine.
-
- (Object) set_ssh_keys(id)
Assigns SSH keys of all administrators and a owner to a virtual machine.
-
- (Object) set_vip(id)
Toggle the VIP status of the virtual machine.
-
- (Object) show(id)
Get info for a virtual machine.
-
- (Object) shutdown(id)
Shutdown a virtual machine.
-
- (Object) startup(id)
Boot a virtual machine.
-
- (Object) stats(id)
Get billing statistics for a virtual machine.
-
- (Object) stop(id)
Stop a virtual machine.
-
- (Object) suspend(id)
Suspend/Unsuspend a virtual machine.
-
- (Object) unlock(id)
Unlock a virtual machine.
Methods inherited from Base
#check_config, #default_params, #key_for_class, #request
Instance Method Details
- (Object) build(id, options = {})
Build a virtual machine.
98 99 100 101 |
# File 'lib/squall/virtual_machine.rb', line 98 def build(id, = {}) response = request(:post, "/virtual_machines/#{id}/build.json", default_params()) response.first[1] end |
- (Object) change_owner(id, user_id)
Change the owner of a virtual machine.
120 121 122 123 |
# File 'lib/squall/virtual_machine.rb', line 120 def change_owner(id, user_id) response = request(:post, "/virtual_machines/#{id}/change_owner.json", query: { user_id: user_id }) response['virtual_machine'] end |
- (Object) change_password(id, password)
Change the password.
131 132 133 134 |
# File 'lib/squall/virtual_machine.rb', line 131 def change_password(id, password) response = request(:post, "/virtual_machines/#{id}/reset_password.json", query: { new_password: password }) response['virtual_machine'] end |
- (Object) console(id)
Open a console for a virtual machine.
275 276 277 278 |
# File 'lib/squall/virtual_machine.rb', line 275 def console(id) response = request(:post, "/virtual_machines/#{id}/console.json") response['virtual_machine'] end |
- (Object) create(options = {})
Create a new virtual machine.
83 84 85 86 |
# File 'lib/squall/virtual_machine.rb', line 83 def create( = {}) response = request(:post, '/virtual_machines.json', default_params()) response['virtual_machine'] end |
- (Object) delete(id)
Delete a virtual machine.
176 177 178 |
# File 'lib/squall/virtual_machine.rb', line 176 def delete(id) request(:delete, "/virtual_machines/#{id}.json") end |
- (Object) edit(id, options = {})
Edit a virtual machine.
109 110 111 112 |
# File 'lib/squall/virtual_machine.rb', line 109 def edit(id, = {}) response = request(:put, "/virtual_machines/#{id}.json", default_params()) response['virtual_machine'] end |
- (Object) list
List all virtual machines.
7 8 9 10 |
# File 'lib/squall/virtual_machine.rb', line 7 def list response = request(:get, '/virtual_machines.json') response.collect { |v| v['virtual_machine'] } end |
- (Object) migrate(id, options = {})
Migrate a virtual machine to a new hypervisor.
157 158 159 |
# File 'lib/squall/virtual_machine.rb', line 157 def migrate(id, = {}) request(:post, "/virtual_machines/#{id}/migrate.json", query: { virtual_machine: } ) end |
- (Object) reboot(id, recovery = false)
Reboot a virtual machine
253 254 255 256 |
# File 'lib/squall/virtual_machine.rb', line 253 def reboot(id, recovery=false) response = request(:post, "/virtual_machines/#{id}/reboot.json", { query: recovery ? { mode: :recovery } : nil }) response['virtual_machine'] end |
- (Object) resize(id, options = {})
Resize a virtual machine's memory.
192 193 194 195 |
# File 'lib/squall/virtual_machine.rb', line 192 def resize(id, = {}) response = request(:post, "/virtual_machines/#{id}/resize.json", default_params()) response['virtual_machine'] end |
- (Object) segregate(id, target_vm_id)
Segregate a virtual machine from another virtual machine.
265 266 267 268 |
# File 'lib/squall/virtual_machine.rb', line 265 def segregate(id, target_vm_id) response = request(:post, "/virtual_machines/#{id}/strict_vm.json", default_params(strict_virtual_machine_id: target_vm_id)) response['virtual_machine'] end |
- (Object) set_ssh_keys(id)
Assigns SSH keys of all administrators and a owner to a virtual machine.
142 143 144 145 |
# File 'lib/squall/virtual_machine.rb', line 142 def set_ssh_keys(id) response = request(:post, "/virtual_machines/#{id}/set_ssh_keys.json") response['virtual_machine'] end |
- (Object) set_vip(id)
Toggle the VIP status of the virtual machine.
166 167 168 169 |
# File 'lib/squall/virtual_machine.rb', line 166 def set_vip(id) response = request(:post, "/virtual_machines/#{id}/set_vip.json") response['virtual_machine'] end |
- (Object) show(id)
Get info for a virtual machine.
17 18 19 20 |
# File 'lib/squall/virtual_machine.rb', line 17 def show(id) response = request(:get, "/virtual_machines/#{id}.json") response.first[1] end |
- (Object) shutdown(id)
Shutdown a virtual machine.
232 233 234 235 |
# File 'lib/squall/virtual_machine.rb', line 232 def shutdown(id) response = request(:post, "/virtual_machines/#{id}/shutdown.json") response['virtual_machine'] end |
- (Object) startup(id)
Boot a virtual machine.
222 223 224 225 |
# File 'lib/squall/virtual_machine.rb', line 222 def startup(id) response = request(:post, "/virtual_machines/#{id}/startup.json") response['virtual_machine'] end |
- (Object) stats(id)
Get billing statistics for a virtual machine.
285 286 287 288 |
# File 'lib/squall/virtual_machine.rb', line 285 def stats(id) response = request(:post, "/virtual_machines/#{id}/vm_stats.json") response['virtual_machine'] end |
- (Object) stop(id)
Stop a virtual machine.
242 243 244 245 |
# File 'lib/squall/virtual_machine.rb', line 242 def stop(id) response = request(:post, "/virtual_machines/#{id}/stop.json") response['virtual_machine'] end |
- (Object) suspend(id)
Suspend/Unsuspend a virtual machine.
202 203 204 205 |
# File 'lib/squall/virtual_machine.rb', line 202 def suspend(id) response = request(:post, "/virtual_machines/#{id}/suspend.json") response['virtual_machine'] end |
- (Object) unlock(id)
Unlock a virtual machine.
212 213 214 215 |
# File 'lib/squall/virtual_machine.rb', line 212 def unlock(id) response = request(:post, "/virtual_machines/#{id}/unlock.json") response['virtual_machine'] end |