Class: Fog::Network::Proxmox::Real

Inherits:
Object
  • Object
show all
Includes:
Proxmox::Core
Defined in:
lib/fog/network/proxmox.rb,
lib/fog/network/proxmox/requests/get_node.rb,
lib/fog/network/proxmox/requests/list_nodes.rb,
lib/fog/network/proxmox/requests/power_node.rb,
lib/fog/network/proxmox/requests/get_network.rb,
lib/fog/network/proxmox/requests/list_networks.rb,
lib/fog/network/proxmox/requests/create_network.rb,
lib/fog/network/proxmox/requests/delete_network.rb,
lib/fog/network/proxmox/requests/update_network.rb

Overview

class Real update_network request

Instance Attribute Summary

Attributes included from Proxmox::Core

#deadline, #principal, #pve_csrftoken, #pve_ticket, #pve_username

Instance Method Summary collapse

Methods included from Proxmox::Core

#credentials, #initialize_identity, not_found_class, #reload

Constructor Details

#initialize(options = {}) ⇒ Real

Returns a new instance of Real


61
62
63
64
65
66
67
68
69
# File 'lib/fog/network/proxmox.rb', line 61

def initialize(options = {})
  initialize_identity(options)
  @connection_options = options[:connection_options] || {}
  @path_prefix = URI.parse(options[:pve_url]).path
  authenticate
  @persistent = options[:persistent] || false
  url = "#{@scheme}://#{@host}:#{@port}"
  @connection = Fog::Core::Connection.new(url, @persistent, @connection_options.merge(path_prefix: @path_prefix))
end

Instance Method Details

#configObject


71
72
73
# File 'lib/fog/network/proxmox.rb', line 71

def config
  self
end

#configure(source) ⇒ Object


75
76
77
78
79
# File 'lib/fog/network/proxmox.rb', line 75

def configure(source)
  source.instance_variables.each do |v|
    instance_variable_set(v, source.instance_variable_get(v))
  end
end

#create_network(path_params, body_params) ⇒ Object


27
28
29
30
31
32
33
34
35
36
# File 'lib/fog/network/proxmox/requests/create_network.rb', line 27

def create_network(path_params, body_params)
  node = path_params[:node]
  response = request(
    expects: [200],
    method: 'POST',
    path: "nodes/#{node}/network",
    body: URI.encode_www_form(body_params)
  )
  Fog::Proxmox::Json.get_data(response)
end

#delete_network(path_params) ⇒ Object


28
29
30
31
32
33
34
35
36
37
# File 'lib/fog/network/proxmox/requests/delete_network.rb', line 28

def delete_network(path_params)
  node = path_params[:node]
  iface = path_params[:iface]
  response = request(
    expects: [200],
    method: 'DELETE',
    path: "nodes/#{node}/network/#{iface}"
  )
  Fog::Proxmox::Json.get_data(response)
end

#get_network(path_params) ⇒ Object


28
29
30
31
32
33
34
35
36
37
# File 'lib/fog/network/proxmox/requests/get_network.rb', line 28

def get_network(path_params)
  node = path_params[:node]
  iface = path_params[:iface]
  response = request(
    expects: [200],
    method: 'GET',
    path: "nodes/#{node}/network/#{iface}"
  )
  Fog::Proxmox::Json.get_data(response)
end

#get_node(node) ⇒ Object


28
29
30
31
32
33
34
35
# File 'lib/fog/network/proxmox/requests/get_node.rb', line 28

def get_node(node)
  response = request(
    expects: [200],
    method: 'GET',
    path: "nodes/#{node}/status"
  )
  Fog::Proxmox::Json.get_data(response)
end

#list_networks(path_params, query_params) ⇒ Object


26
27
28
29
30
31
32
33
34
# File 'lib/fog/network/proxmox/requests/list_networks.rb', line 26

def list_networks(path_params, query_params)
  node = path_params[:node]
  request(
    expects: [200],
    method: 'GET',
    path: "nodes/#{node}/network",
    query: URI.encode_www_form(query_params)
  )
end

#list_nodesObject


26
27
28
29
30
31
32
33
# File 'lib/fog/network/proxmox/requests/list_nodes.rb', line 26

def list_nodes
  request(
    expects: [200],
    method: 'GET',
    path: 'cluster/resources',
    query: 'type=node'
  )
end

#power_node(path_params, body_params) ⇒ Object


28
29
30
31
32
33
34
35
36
37
# File 'lib/fog/network/proxmox/requests/power_node.rb', line 28

def power_node(path_params, body_params)
  node = path_params[:node]
  response = request(
    expects: [200],
    method: 'POST',
    path: "nodes/#{node}/status",
    body: URI.encode_www_form(body_params)
  )
  Fog::Proxmox::Json.get_data(response)
end

#update_network(path_params, body_params) ⇒ Object


27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fog/network/proxmox/requests/update_network.rb', line 27

def update_network(path_params, body_params)
  node = path_params[:node]
  iface = path_params[:iface]
  response = request(
    expects: [200],
    method: 'PUT',
    path: "nodes/#{node}/network/#{iface}",
    body: URI.encode_www_form(body_params)
  )
  Fog::Proxmox::Json.get_data(response)
end