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

#create(options = {}) ⇒ Object

Public: Create a Network.

options - Params for creating the Network:

:label
:vlan
:identifier

Example

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

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

#delete(id) ⇒ Object

Public: Delete a network.

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

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

Public: Edit a Network

id - ID of the network options - 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

#listObject

Public: 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

#rebuild(id) ⇒ Object

Public: Rebuild VM network.

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