Class: Netconf::RPC::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/sloe/common.rb

Instance Method Summary collapse

Constructor Details

#initialize(trans, os_type, logging) ⇒ Executor

Returns a new instance of Executor.



64
65
66
67
68
69
70
71
72
# File 'lib/sloe/common.rb', line 64

def initialize( trans, os_type, logging )
  @trans = trans
  @logging = logging
  begin  
    extend Netconf::RPC::const_get( os_type )                
  rescue NameError
    # no extensions available ...
  end        
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, params = nil, attrs = nil) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/sloe/common.rb', line 74

def method_missing( method, params = nil, attrs = nil )
  rpc = Netconf::RPC::Builder.send( method, params, attrs )
  if @logging
    log_attrs = attrs ? attrs : {}
    log_attrs[:format] = 'text'
    Dir.mkdir @logging[:path]
    File.open("#{@logging[:path]}/#{@logging[:file]}", "w") { |file| 
      file.write rpc
      file.write @trans.rpc_exec( Netconf::RPC::Builder.send( method, params, log_attrs ))
    }
  end
  @trans.rpc_exec( rpc )
end