module Netconf

Copyright © 2012 Juniper Networks, Inc. All Rights Reserved

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


This file contains the Junos specific RPC methods that are generated specifically and different as generated by the Netconf::RPC::Builder module. These are specifically the following:

get_configuration      - alternative NETCONF: 'get-config'
load_configuration     - alternative NETCONF: 'edit-config'
lock_configuration     - alternative NETCONF: 'lock'
commit_configuration   - alternative NETCONF: 'commit'

note: unlock_configuration is not included in this file since

the Netconf::RPC::Builder works "as-is" in this case


This file contains the Netconf::Transport parent class definition. All other transports, i.e. “ssh”, “serial”, “telnet” use this parent class to define their transport specific methods:

trans_open: open the transport connection
trans_close: close the transport connection
trans_send: send XML command (String) via transport
trans_receive: receive XML response (String) via transport

Constants

DEFAULT_OS_TYPE
DEFAULT_TIMEOUT
DEFAULT_WAITIO
NAMESPACE
VERSION

Public Class Methods

raise_on_warning() click to toggle source
# File lib/net/netconf.rb, line 21
def self.raise_on_warning
  @raise_on_warning
end
raise_on_warning=( bool ) click to toggle source
# File lib/net/netconf.rb, line 17
def self.raise_on_warning=( bool )
  @raise_on_warning = bool
end
trans_receive() click to toggle source
# 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) click to toggle source
# 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