Class: Squall::Network

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

Overview

OnApp Network

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) create(options = {})

Create a Network.

Examples:

create(
  label:            'mynetwork',
  network_group_id: 1,
  vlan:             2,
  identifier:       'something'
)

Parameters:

  • options (defaults to: {})

    Params for creating the Network: :label :vlan :identifier

Returns:

  • a Hash.



29
30
31
32
# File 'lib/squall/network.rb', line 29

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

- (Object) delete(id)

Delete a network.

Parameters:

  • id

    ID of the network

Returns:

  • a Hash.



49
50
51
# File 'lib/squall/network.rb', line 49

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

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

Edit a Network

Parameters:

  • id

    ID of the network

  • options (defaults to: {})

    Params for editing the Network, see `#create`

Returns:

  • a Hash.



40
41
42
# File 'lib/squall/network.rb', line 40

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

- (Object) list

Lists all networks.

Returns:

  • an Array.



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

def list
  response = request(:get, '/settings/networks.json')
  response.collect { |network| network['network'] }
end

- (Object) rebuild(id)

Rebuild VM network.

Parameters:

  • id

    ID of the virtual machine

Returns:

  • a Hash.



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

def rebuild(id)
  request(:post, "/virtual_machines/#{id}/rebuild_network.json")
end