Class: Puppet::NetDev::CE::Command_sshApi
- Defined in:
- lib/puppet/provider/ce/api/command_ssh/command_ssh_api.rb
Instance Method Summary collapse
- #command_ssh(resource) ⇒ Object
-
#initialize ⇒ Command_sshApi
constructor
A new instance of Command_sshApi.
Constructor Details
#initialize ⇒ Command_sshApi
Returns a new instance of Command_sshApi.
25 26 27 |
# File 'lib/puppet/provider/ce/api/command_ssh/command_ssh_api.rb', line 25 def initialize super() end |
Instance Method Details
#command_ssh(resource) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/puppet/provider/ce/api/command_ssh/command_ssh_api.rb', line 29 def command_ssh(resource) session = Puppet::NetDev::CE::Device_ssh.ssh_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.write(resource[:command][i] + "\n") session.waitfor('Match' => /<>/, 'Timeout' => 5) { |c| myfile.puts c } end myfile.close end |