36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/fluent/plugin/in_telemetry_iosxe.rb', line 36
def start
super
@sigint = false
trap :INT do
log.info "got SIGINT ..."
@sigint = true
end
@hello_done = false
@subscription_index = 0
@subscription_ids = []
@buffer = ""
@parser = Nori.new(:parser => @parser, :advanced_typecasting => false)
hello = <<-EOS
<?xml version="1.0" encoding="UTF-8"?>
<hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<capabilities>
<capability>urn:ietf:params:netconf:base:1.0</capability>
<capability>urn:ietf:params:netconf:base:1.1</capability>
</capabilities>
</hello>]]>]]>
EOS
@ssh = Net::SSH.start(@server, @user, :port => @port, :password => @password, :timeout => 10)
@channel = @ssh.open_channel do |channel|
channel.subsystem("netconf") do |ch, success|
raise "subsystem could not be started" unless success
ch.on_data do |c, data|
log.debug "on data ..."
log.debug data
receive_data(data)
end
ch.on_close do |c|
log.debug "on close ..."
end
ch.on_eof do |c|
log.debug "on eof ..."
end
log.info "send hello"
ch.send_data(hello)
end
end
@ssh.loop(1) { not @sigint } end
|