Class: Squall::Disk

Inherits:
Base
  • Object
show all
Defined in:
lib/squall/disk.rb

Overview

OnApp Disk

Instance Attribute Summary

Attributes inherited from Base

#result, #success

Instance Method Summary collapse

Methods inherited from Base

#check_config, #default_params, #key_for_class, #request

Instance Method Details

#add_schedule(id, options = {}) ⇒ Object

Public: Add autobackup schedule to a disk

id - ID of the disk options - Params for the disk

:action   - set Autobackup to add a backup schedule
:duration - specify duration
:period   - set the period (days|weeks|months|years)

Example

params = {
  action:   'autobackup',
  duration: 10,
  period:   days
}

Returns an Array.



151
152
153
# File 'lib/squall/disk.rb', line 151

def add_schedule(id, options = {})
  request(:post, "/settings/disks/#{id}/schedules.json", default_params(options))
end

#auto_backup_off(id) ⇒ Object

Public: Disable autobackups for a disk

id - ID of the disk

Returns a Hash.



119
120
121
122
# File 'lib/squall/disk.rb', line 119

def auto_backup_off(id)
  response = request(:post, "/settings/disks/#{id}/autobackup_disable.json")
  response['disk']
end

#auto_backup_on(id) ⇒ Object

Public: Enable autobackups for a disk.

id - ID of the disk

Returns a Hash.



109
110
111
112
# File 'lib/squall/disk.rb', line 109

def auto_backup_on(id)
  response = request(:post, "/settings/disks/#{id}/autobackup_enable.json")
  response['disk']
end

#backups(id) ⇒ Object

Public: List backups available for a disk.

id - ID of the disk

Returns an Array.



160
161
162
163
# File 'lib/squall/disk.rb', line 160

def backups(id)
  response = request(:get, "/settings/disks/#{id}/backups.json")
  response.collect { |i| i['backup'] }
end

#build(id) ⇒ Object

Public: Builds a disk.

id - ID of the disk

Returns a Hash.



89
90
91
92
# File 'lib/squall/disk.rb', line 89

def build(id)
  response = request(:post, "/settings/disks/#{id}/build.json")
  response['disk']
end

#create(id, options = {}) ⇒ Object

Public: Creates a new Disk.

id - ID of the virtual machine options - Params for the disk:

:add_to_linux_fstab  - Set true to add
:data_store_id       - The ID of a data store where this disk is
                       located
:disk_size           - The disk space in GB
:is_swap             - Set true if this is a swap disk
:mount_point         - a physical location in the partition used
                       as a root filesystem
:require_format_disk 

Example

create(
  add_to_linux_fstab:  1,
  data_store_id:       1,
  disk_size:           10,
  is_swap:             0,
  mount_point:         '/disk2',
  require_format_disk: 1
)

Returns a Hash.



47
48
49
# File 'lib/squall/disk.rb', line 47

def create(id, options = {})
  request(:post, "/virtual_machines/#{id}/disks.json", default_params(options))
end

#delete(id) ⇒ Object

Public: Delete a disk.

id - ID of the disk

Returns a Hash.



170
171
172
# File 'lib/squall/disk.rb', line 170

def delete(id)
  request(:delete, "/settings/disks/#{id}.json")
end

#edit(id, options = {}) ⇒ Object

Public: Updates an existing disk.

id - ID of the disk options - Params for the disk

:disk_size - The disk space in GB

Returns a Hash.



58
59
60
# File 'lib/squall/disk.rb', line 58

def edit(id, options = {})
  request(:put, "/settings/disks/#{id}.json", default_params(options))
end

#iops_usage(id) ⇒ Object

Public: View Input/Output statistics for a disk.

id - ID of the disk

Returns an Array



79
80
81
82
# File 'lib/squall/disk.rb', line 79

def iops_usage(id)
  response = request(:get, "/settings/disks/#{id}/usage.json")
  response.collect { |i| i['disk_hourly_stat'] }
end

#listObject

Public: List all disks.

Returns an Array.



7
8
9
10
# File 'lib/squall/disk.rb', line 7

def list
  response = request(:get, "/settings/disks.json")
  response.collect { |i| i['disk'] }
end

#migrate(vm_id, id, options = {}) ⇒ Object

Public: Migrates a VM disk to another data store.

vm_id - ID of the virtual machine id - ID of the disk options - Params for the disk

:data_store_id - The disk space in GB

Returns a Hash.



70
71
72
# File 'lib/squall/disk.rb', line 70

def migrate(vm_id, id, options = {})
  request(:post, "/virtual_machines/#{vm_id}/disks/#{id}/migrate.json", default_params(options))
end

#schedules(id) ⇒ Object

Public: Get the list of schedules for a disk.

id - ID of the disk

Returns an Array.



129
130
131
132
# File 'lib/squall/disk.rb', line 129

def schedules(id)
  response = request(:get, "/settings/disks/#{id}/schedules.json")
  response.collect { |i| i['schedule'] }
end

#unlock(id) ⇒ Object

Public: Unlock a disk.

id - ID of the disk

Returns a Hash.



99
100
101
102
# File 'lib/squall/disk.rb', line 99

def unlock(id)
  response = request(:post, "/settings/disks/#{id}/unlock.json")
  response['disk']
end

#vm_disk_list(id) ⇒ Object

Public: List all disks available for a particular VM.

id - ID of the virtual machine

Returns an Array.



17
18
19
20
# File 'lib/squall/disk.rb', line 17

def vm_disk_list(id)
  response = request(:get, "/virtual_machines/#{id}/disks.json")
  response.collect { |i| i['disk'] }
end