Class: Netconf::NetconfClient

Inherits:
Object
  • Object
show all
Defined in:
lib/util/client/netconf/netconf_client.rb

Overview

Netconf client class

1

defines the netconf frame parsers

2

connects to SSH

3

defines a few frame parsing classes for the various response types for Netconf/SSH

Defined Under Namespace

Classes: CommitResponse, EditConfigResponse, GetConfigResponse, GetResponse, RpcResponse

Instance Method Summary collapse

Constructor Details

#initialize(login, options = {}) ⇒ NetconfClient

Returns a new instance of NetconfClient.



502
503
504
505
506
507
# File 'lib/util/client/netconf/netconf_client.rb', line 502

def initialize(, options={})
  debug "Netconf::NetconfClient started with login: #{} and options: #{options}"
  @login = 
  @ssh = nil
  @options = options
end

Instance Method Details

#closeObject



555
556
557
558
# File 'lib/util/client/netconf/netconf_client.rb', line 555

def close
  debug 'Netconf::NetconfClient close'
  @ssh.close if @ssh
end

#commit_changesObject



543
544
545
546
547
548
# File 'lib/util/client/netconf/netconf_client.rb', line 543

def commit_changes
  debug 'Netconf::NetconfClient commit_changes'
  rsp = CommitResponse.new(tx_request_and_rx_reply(Format.format_commit_msg(@message_id)))
  debug "Netconf::NetconfClient commit_changes returned #{rsp.response}"
  rsp
end

#connectObject



497
498
499
500
# File 'lib/util/client/netconf/netconf_client.rb', line 497

def connect
  debug 'Netconf::NetconfClient connecting by request'
  connect_internal
end

#edit_config(target, default_operation, config) ⇒ Object



529
530
531
532
533
534
535
536
537
538
539
540
541
# File 'lib/util/client/netconf/netconf_client.rb', line 529

def edit_config(target, default_operation, config)
  debug 'Netconf::NetconfClient edit_config'
  debug "target:\n#{target}"
  debug "default_operation: #{default_operation}"
  debug "config:\n#{config}"
  msg = Format.format_edit_config_msg(@message_id,
                                      default_operation,
                                      target,
                                      config)
  rsp = EditConfigResponse.new(tx_request_and_rx_reply(msg))
  debug "Netconf::NetconfClient edit_config returned #{rsp.response}"
  rsp
end

#get_config(filter) ⇒ Object



517
518
519
520
521
522
523
524
525
526
527
# File 'lib/util/client/netconf/netconf_client.rb', line 517

def get_config(filter)
  debug "Netconf::NetconfClient get_config with filter #{filter}"
  if filter == '' || filter.nil?
    msg = Format.format_get_config_all_msg(@message_id)
  else
    msg = Format.format_get_config_msg(@message_id, filter)
  end
  rsp = GetResponse.new(tx_request_and_rx_reply(msg))
  debug "Netconf::NetconfClient get_config returned #{rsp.response}"
  rsp
end

#get_oper(filter) ⇒ Object



509
510
511
512
513
514
515
# File 'lib/util/client/netconf/netconf_client.rb', line 509

def get_oper(filter)
  debug "Netconf::NetconfClient get_oper with filter #{filter}"
  msg = Format.format_get_msg(@message_id, filter)
  rsp = GetResponse.new(tx_request_and_rx_reply(msg))
  debug "Netconf::NetconfClient get_oper returned #{rsp.response}"
  rsp
end

#stopObject



550
551
552
553
# File 'lib/util/client/netconf/netconf_client.rb', line 550

def stop
  debug 'Netconf::NetconfClient stop'
  tx_request_and_rx_reply(Format.format_close_session(@message_id))
end