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 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n<capabilities>\n<capability>urn:ietf:params:netconf:base:1.0</capability>\n</capabilities>\n</hello>]]>]]>\n"
subscription = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<rpc message-id=\"101\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n<establish-subscription xmlns=\"urn:ietf:params:xml:ns:yang:ietf-event-notifications\" xmlns:yp=\"urn:ietf:params:xml:ns:yang:ietf-yang-push\">\n<stream>yp:yang-push</stream>\n<yp:xpath-filter>\#{@xpath_filter}</yp:xpath-filter>\n<yp:period>\#{@period}</yp:period>\n</establish-subscription>\n</rpc>\n"
@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
|