class OmfEc::Context::NetContext

Holds network related configuration

Constants

FREQUENCY

Wifi frequency channel matching

Attributes

conf[RW]

Public Class Methods

new(opts) click to toggle source
# File lib/omf_ec/context/net_context.rb, line 22
def initialize(opts)
  self.conf = opts
  self
end

Public Instance Methods

map_channel_freq() click to toggle source

Interchange channel and frequency value

# File lib/omf_ec/context/net_context.rb, line 48
def map_channel_freq
  if self.conf[:channel] && self.conf[:frequency].nil?
    self.conf[:frequency] = FREQUENCY[self.conf[:channel].to_s.to_i]
  end
  if self.conf[:channel].nil? && self.conf[:frequency]
    self.conf[:channel] = FREQUENCY.keys.find { |k| FREQUENCY[k] == self.conf[:frequency].to_sto_i }
  end
  self
end
method_missing(name, *args, &block) click to toggle source

Property assignment will simply update configuration

@example OEDL

node.net.w0.mode = "adhoc"
node.net.w0.essid = "helloworld"
Calls superclass method
# File lib/omf_ec/context/net_context.rb, line 32
def method_missing(name, *args, &block)
  if name =~ /(.+)=/
    net_prop = $1.to_sym
    net_prop = case net_prop
               when :type then :hw_mode
               when :ip then :ip_addr
               else
                 net_prop
               end
    self.conf.merge!(net_prop => args[0].to_s)
  else
    super
  end
end