class Squall::Disk

OnApp Disk

Public Instance Methods

add_schedule(id, options = {}) click to toggle source

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.

# 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) click to toggle source

Public: Disable autobackups for a disk

id - ID of the disk

Returns a Hash.

# 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) click to toggle source

Public: Enable autobackups for a disk.

id - ID of the disk

Returns a Hash.

# 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) click to toggle source

Public: List backups available for a disk.

id - ID of the disk

Returns an Array.

# 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) click to toggle source

Public: Builds a disk.

id - ID of the disk

Returns a Hash.

# File lib/squall/disk.rb, line 89
def build(id)
  response = request(:post, "/settings/disks/#{id}/build.json")
  response['disk']
end
create(id, options = {}) click to toggle source

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 – set true to 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.

# File lib/squall/disk.rb, line 47
def create(id, options = {})
  request(:post, "/virtual_machines/#{id}/disks.json", default_params(options))
end
delete(id) click to toggle source

Public: Delete a disk.

id - ID of the disk

Returns a Hash.

# File lib/squall/disk.rb, line 170
def delete(id)
  request(:delete, "/settings/disks/#{id}.json")
end
edit(id, options = {}) click to toggle source

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.

# File lib/squall/disk.rb, line 58
def edit(id, options = {})
  request(:put, "/settings/disks/#{id}.json", default_params(options))
end
iops_usage(id) click to toggle source

Public: View Input/Output statistics for a disk.

id - ID of the disk

Returns an Array

# 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
list() click to toggle source

Public: List all disks.

Returns an Array.

# 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 = {}) click to toggle source

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.

# 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) click to toggle source

Public: Get the list of schedules for a disk.

id - ID of the disk

Returns an Array.

# 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) click to toggle source

Public: Unlock a disk.

id - ID of the disk

Returns a Hash.

# 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) click to toggle source

Public: List all disks available for a particular VM.

id - ID of the virtual machine

Returns an Array.

# 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