Class: Puppet::NetDev::CE::Command_telnetApi

Inherits:
ApiBase
  • Object
show all
Defined in:
lib/puppet/provider/ce/api/command_telnet/command_telnet_api.rb

Instance Method Summary collapse

Constructor Details

#initializeCommand_telnetApi

Returns a new instance of Command_telnetApi.



24
25
26
# File 'lib/puppet/provider/ce/api/command_telnet/command_telnet_api.rb', line 24

def initialize
  super()
end

Instance Method Details

#command_telnet(resource) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/puppet/provider/ce/api/command_telnet/command_telnet_api.rb', line 28

def command_telnet(resource)
session = Puppet::NetDev::CE::Device_tel.telnet_session

myfile = File.open('/tmp/hello.txt', 'a')
t = Time.now
format = '%Y-%m-%d %H:%M:%S'
myfile.puts t.strftime(format)

for i in 0..resource[:command].count - 1 do
  session.cmd('String' => resource[:command][i], 'Match' => /.*/, 'Timeout' => 5) { |c| myfile.puts c }
end
session.cmd('String' => 'q', 'Match' => /.*>/, 'Timeout' => 5) { |c| }
myfile.close
end