NetDocuments-Archive / rd-winrm-plugin

Allows rundeck to execute commands with powershell
Apache License 2.0
31 stars 19 forks source link

WinRMWebService deorecation (use CommandExecutor) #17

Closed xeor closed 8 years ago

xeor commented 8 years ago

I saw a mention about this issue in https://github.com/NetDocuments/rd-winrm-plugin/issues/9, but I think a dedicated issue for it is better.

For every run, I am now getting an error;

WARN  WinRM::WinRMWebService : WinRM::WinRMWebService#run_powershell_script is deprecated. Use WinRM::CommandExecutor#run_powershell_script instead

This is mentioned on https://github.com/WinRb/WinRM#deprecated-methods as well.

I don't know enough ruby to feel comfortable sending in a pull-request, but I where able to get rid of the warning with some small tweeks to winrmexe.rb. Basically, adding executor = WinRM::CommandExecutor.new(winrm) and executor.open at L101 (https://github.com/NetDocuments/rd-winrm-plugin/blob/master/contents/winrmexe.rb#L101) and replacing the result = winrm.powershell(command) lines with executor.run_powershell_script, ...run_cmd, and run_wql. And finally putting executor.close around L110..

vvchik commented 8 years ago

Hmm, looks good, I will check this.

spuder commented 8 years ago

The logic seems sane. I haven't looked enough at the code base to know if passing the WinRMWebService object to a new WinRM::CommandExecutor is the 'correct' way to fix this. I think it is likely going down the right track.

aaronmaxlevy commented 8 years ago

I addressed this in PR #24

vvchik commented 8 years ago

Cool, thank you @aaronmaxlevy