Module: Netconf

Defined in:
lib/net/netconf/jnpr/rpc.rb,
lib/net/netconf.rb,
lib/net/netconf/rpc.rb,
lib/net/netconf/ssh.rb,
lib/net/netconf/ioproc.rb,
lib/net/netconf/serial.rb,
lib/net/netconf/telnet.rb,
lib/net/netconf/rpc_std.rb,
lib/net/netconf/version.rb,
lib/net/netconf/jnpr/ssh.rb,
lib/net/netconf/exception.rb,
lib/net/netconf/transport.rb,
lib/net/netconf/jnpr/ioproc.rb,
lib/net/netconf/jnpr/serial.rb,
lib/net/netconf/jnpr/telnet.rb,
lib/net/netconf/jnpr/junos_config.rb

Overview

Copyright © 2012 Juniper Networks, Inc. All Rights Reserved

JUNIPER PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.

Defined Under Namespace

Modules: Junos, RPC Classes: CommitError, EditError, IOProc, InitError, JunosConfig, LockError, OpenError, RpcError, SSH, Serial, StateError, Telnet, Transport, ValidateError

Constant Summary collapse

NAMESPACE =
"urn:ietf:params:xml:ns:netconf:base:1.0"
DEFAULT_OS_TYPE =
:Junos
DEFAULT_TIMEOUT =
10
DEFAULT_WAITIO =
0
VERSION =
'0.4.3'

Class Method Summary collapse

Class Method Details

.raise_on_warningObject


21
22
23
# File 'lib/net/netconf.rb', line 21

def self.raise_on_warning
  @raise_on_warning
end

.raise_on_warning=(bool) ⇒ Object


17
18
19
# File 'lib/net/netconf.rb', line 17

def self.raise_on_warning=( bool )
  @raise_on_warning = bool
end

.trans_receiveObject


55
56
57
58
59
60
# File 'lib/net/netconf.rb', line 55

def self.trans_receive
  got = waitfor( Netconf::RPC::MSG_END_RE )
  msg_end = got.rindex( Netconf::RPC::MSG_END )
  got[msg_end .. -1] = ''
  got
end

.waitfor(on_re = nil) ⇒ Object


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/net/netconf.rb', line 25

def self.waitfor(on_re = nil)
  time_out = @trans_timeout
  wait_io = @trans_waitio

  time_out = nil if time_out == false
  done = false
  rx_buf = ''

  until( rx_buf.match( on_re ) and not IO::select( [@trans], nil, nil, wait_io ) )

    unless IO::select( [@trans], nil, nil, time_out )
      raise TimeoutError, 'Netconf IO timed out while waiting for more data'
    end

    begin

      rx_some = @trans.readpartial( DEFAULT_RDBLKSZ )

      rx_buf += rx_some
      break if rx_buf.match( on_re )

    rescue EOFError # End of file reached
      rx_buf = nil if rx_buf == ''
      break   # out of outer 'until' loop
    end

  end
  rx_buf
end