35
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
79
80
81
82
83
84
85
86
87
|
# File 'lib/fluent/plugin/in_telemetry_iosxe.rb', line 35
def start
super
@sigint = false
trap :INT do
log.info "got SIGINT ..."
@sigint = true
end
@hello_done = false
@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>
</capabilities>
</hello>]]>]]>
EOS
subscription = <<-EOS
<?xml version="1.0" encoding="utf-8"?>
<rpc message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<establish-subscription xmlns="urn:ietf:params:xml:ns:yang:ietf-event-notifications" xmlns:yp="urn:ietf:params:xml:ns:yang:ietf-yang-push">
<stream>yp:yang-push</stream>
<yp:xpath-filter>#{@xpath_filter}</yp:xpath-filter>
<yp:period>#{@period}</yp:period>
</establish-subscription>
</rpc>
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)
log.info "send subscription"
ch.send_data(subscription)
end
end
@ssh.loop(1) { not @sigint } end
|