Class: Squall::Hypervisor

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

Overview

OnApp Hypervisor

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_data_store_join(id, data_store_id)

TODO: Add documentation



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

def add_data_store_join(id, data_store_id)
  request(:post, "/settings/hypervisors/#{id}/data_store_joins.json", query: { data_store_id:  data_store_id })
end

- (Object) add_network_join(id, options)

TODO: Add documentation



105
106
107
# File 'lib/squall/hypervisor.rb', line 105

def add_network_join(id, options)
  request(:post, "/settings/hypervisors/#{id}/network_joins.json", query: { network_join: options })
end

- (Object) create(options = {})

Create a new Hypervisor.

Examples:

create(
  label:           'myhv',
  ip_address:      '127.0.0.1',
  hypervisor_type: 'xen'
)

Parameters:

  • options (defaults to: {})

    Options for creating the hypervisor:

Options Hash (options):

  • :label (Object)

    Label for the hypervisor

  • :ip_address (Object)

    IP for the hypervisor

  • :hypervisor_type (Object)

    Type of the hypervisor

Returns:

  • a Hash.



38
39
40
41
# File 'lib/squall/hypervisor.rb', line 38

def create(options = {})
  req = request(:post, '/settings/hypervisors.json', default_params(options))
  req.first[1]
end

- (Object) data_store_joins(id)

TODO: Add documentation



83
84
85
86
# File 'lib/squall/hypervisor.rb', line 83

def data_store_joins(id)
  response = request(:get, "/settings/hypervisors/#{id}/data_store_joins.json")
  response.collect { |dsj| dsj['data_store_join'] }
end

- (Object) delete(id)

Delete a hypervisor

Parameters:

  • id

    ID of the hypervisor

Returns:

  • a Hash.



72
73
74
# File 'lib/squall/hypervisor.rb', line 72

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

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

Edit a Hypervisor.

Examples:

edit 1, label: 'myhv', ip_address: '127.0.0.1'

Parameters:

  • id

    ID of the hypervisor

  • options (defaults to: {})

    Params for editing the Hypervisor, see `#create`.

Returns:

  • a Hash.



53
54
55
# File 'lib/squall/hypervisor.rb', line 53

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

- (Object) list

Lists all hypervisors.

Returns:

  • an Array.



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

def list
  req = request(:get, '/settings/hypervisors.json')
  req.collect { |hv| hv['hypervisor'] }
end

- (Object) network_joins(id)

TODO: Add documentation



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

def network_joins(id)
  response = request(:get, "/settings/hypervisors/#{id}/network_joins.json")
  response.collect { |nj| nj['network_join'] }
end

- (Object) reboot(id)

Reboot a hypervisor.

Parameters:

  • id

    ID of the hypervisor

Returns:

  • a Hash.



62
63
64
65
# File 'lib/squall/hypervisor.rb', line 62

def reboot(id)
  response = request(:get, "/settings/hypervisors/#{id}/rebooting.json")
  response['hypervisor']
end

- (Object) remove_data_store_join(id, data_store_join_id)

TODO: Add documentation



94
95
96
# File 'lib/squall/hypervisor.rb', line 94

def remove_data_store_join(id, data_store_join_id)
  request(:delete, "/settings/hypervisors/#{id}/data_store_joins/#{data_store_join_id}.json")
end

- (Object) remove_network_join(id, network_join_id)

TODO: Add documentation



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

def remove_network_join(id, network_join_id)
  request(:delete, "/settings/hypervisors/#{id}/network_joins/#{network_join_id}.json")
end

- (Object) show(id)

Retrieves hypervisor info.

Parameters:

  • id

    The id of the hypervisor

Returns:

  • a Hash.



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

def show(id)
  req = request(:get, "/settings/hypervisors/#{id}.json")
  req.first[1]
end

- (Object) virtual_machines(id)

TODO: Add documentation



77
78
79
80
# File 'lib/squall/hypervisor.rb', line 77

def virtual_machines(id)
  response = request(:get, "/settings/hypervisors/#{id}/virtual_machines.json")
  response.collect { |vm| vm['virtual_machine'] }
end