Module: OmfRc::ResourceProxy::Node

Includes:
OmfRc::ResourceProxyDSL, Util::Mod, Util::Sysfs
Defined in:
lib/omf_rc/resource_proxy/node.rb

Overview

This proxy represents physical/virtual machine node, and it is the proxy which standard RC start up script initialised.

Node proxy is more like a monitor proxy which monitors resource information on the node itself, it is usually created during the bootstrap process and provides an entry point for incoming FRCP messages.

Resources like application, net, or wlan can be created as children of node resources by sending FRCP create messages to the node’s pubsub topic.

Examples:

Creating an ethernet resource on an existing node ‘node01’ using communicator

comm.subscribe('node01') do |node|
  node.create(:net, if_name: 'eth0')
end

Creating an ethernet resource on an existing node ‘node01’ directly

node = OmfRc::ResourceFactory.create(:node)
node.create(:net, if_name: 'eth0')

See Also:

Constant Summary

Constants included from OmfRc::ResourceProxyDSL

OmfRc::ResourceProxyDSL::DEFAULT_PROP_ACCESS, OmfRc::ResourceProxyDSL::PROXY_DIR, OmfRc::ResourceProxyDSL::UTIL_DIR

Instance Method Summary collapse

Methods included from Util::Sysfs

#request_devices, #request_wlan_devices

Methods included from OmfRc::ResourceProxyDSL

#call_hook, #hook_defined?, included

Methods included from Util::Mod

#configure_load_module, #request_modules

Instance Method Details

#before_createObject

Check if device exists

Raises:

  • (StandardError)

    if device not found on the node



73
74
75
76
77
78
79
80
# File 'lib/omf_rc/resource_proxy/node.rb', line 73

hook :before_create do |node, type, opts|
  if type.to_sym == :net
    net_dev = node.request_devices.find do |v|
      v[:name] == opts[:if_name]
    end
    raise StandardError, "Device '#{opts[:if_name]}' not found" if net_dev.nil?
  end
end

#request_applicationsArray<Hash>

Created applications

Examples:

[{ name: 'my_app', type: 'application', uid: 'E232ER1' }]

Returns:

  • (Array<Hash>)


58
59
60
61
62
# File 'lib/omf_rc/resource_proxy/node.rb', line 58

request :applications do |node|
  node.children.find_all { |v| v.type =~ /application/ }.map do |v|
    { name: v.hrn, type: v.type, uid: v.uid }
  end.sort { |x, y| x[:name] <=> y[:name] }
end

#request_interfaceArray<Hash>

Created interfaces

Examples:

[{ name: 'eth0', type: 'net', uid: 'RWED2123' }]

Returns:

  • (Array<Hash>)


45
46
47
48
49
# File 'lib/omf_rc/resource_proxy/node.rb', line 45

request :interfaces do |node|
  node.children.find_all { |v| v.type == :net || v.type == :wlan }.map do |v|
    { name: v.property.if_name, type: v.type, uid: v.uid }
  end.sort { |x, y| x[:name] <=> y[:name] }
end