class Chef::Knife::Winrm
Attributes
password[W]
Public Instance Methods
execute_remote_command()
click to toggle source
# File lib/chef/knife/winops_winrm.rb, line 60 def execute_remote_command case @name_args[1] when "interactive" interactive else run_command(@name_args[1..-1].join(" ")) end end
run()
click to toggle source
# File lib/chef/knife/winops_winrm.rb, line 48 def run STDOUT.sync = STDERR.sync = true configure_session exit_status = execute_remote_command if exit_status != 0 exit exit_status else exit_status end end
Private Instance Methods
interactive()
click to toggle source
# File lib/chef/knife/winops_winrm.rb, line 71 def interactive puts "WARN: Deprecated functionality. This will not be supported in future knife-winops releases." puts "Connected to #{ui.list(session.servers.collect { |s| ui.color(s.host, :cyan) }, :inline, " and ")}" puts puts "To run a command on a list of servers, do:" puts " on SERVER1 SERVER2 SERVER3; COMMAND" puts " Example: on latte foamy; echo foobar" puts puts "To exit interactive mode, use 'quit!'" puts while 1 command = read_line case command when 'quit!' puts 'Bye!' break when /^on (.+?); (.+)$/ raw_list = $1.split(" ") server_list = Array.new @winrm_sessions.each do |session_server| server_list << session_server if raw_list.include?(session_server.host) end command = $2 relay_winrm_command(command, server_list) else relay_winrm_command(command) end end end
read_line()
click to toggle source
Present the prompt and read a single line from the console. It also detects ^D and returns “exit” in that case. Adds the input to the history, unless the input is empty. Loops repeatedly until a non-empty line is input.
# File lib/chef/knife/winops_winrm.rb, line 105 def read_line loop do command = reader.readline("#{ui.color('knife-winrm>', :bold)} ", true) if command.nil? command = "exit" puts(command) else command.strip! end unless command.empty? return command end end end
reader()
click to toggle source
# File lib/chef/knife/winops_winrm.rb, line 122 def reader Readline end