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

- (Object) add_schedule(id, options = {})

Add autobackup schedule to a disk

Examples:

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

Parameters:

  • id

    ID of the disk

  • options (defaults to: {})

    Params for the disk

Options Hash (options):

  • :action (Object)

    set Autobackup to add a backup schedule

  • :duration (Object)

    specify duration

  • :period (Object)

    set the period (days|weeks|months|years)

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

- (Object) auto_backup_off(id)

Disable autobackups for a disk

Parameters:

  • 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

- (Object) auto_backup_on(id)

Enable autobackups for a disk.

Parameters:

  • 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

- (Object) backups(id)

List backups available for a disk.

Parameters:

  • 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

- (Object) build(id)

Builds a disk.

Parameters:

  • 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

- (Object) create(id, options = {})

Creates a new Disk.

Examples:

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

Parameters:

  • id

    ID of the virtual machine

  • options (defaults to: {})

    Params for the disk:

Options Hash (options):

  • :add_to_linux_fstab (Object)

    Set true to add

  • :data_store_id (Object)

    The ID of a data store where this disk is located

  • :disk_size (Object)

    The disk space in GB

  • :is_swap (Object)

    Set true if this is a swap disk

  • :mount_point (Object)

    a physical location in the partition used as a root filesystem

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

- (Object) delete(id)

Delete a disk.

Parameters:

  • 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

- (Object) edit(id, options = {})

Updates an existing disk.

Parameters:

  • id

    ID of the disk

  • options (defaults to: {})

    Params for the disk

Options Hash (options):

  • :disk_size (Object)

    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

- (Object) iops_usage(id)

View Input/Output statistics for a disk.

Parameters:

  • 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

- (Object) list

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

- (Object) migrate(vm_id, id, options = {})

Migrates a VM disk to another data store.

Parameters:

  • vm_id

    ID of the virtual machine

  • id

    ID of the disk

  • options (defaults to: {})

    Params for the disk

Options Hash (options):

  • :data_store_id (Object)

    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

- (Object) schedules(id)

Get the list of schedules for a disk.

Parameters:

  • 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

- (Object) unlock(id)

Unlock a disk.

Parameters:

  • 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

- (Object) vm_disk_list(id)

List all disks available for a particular VM.

Parameters:

  • 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