| Total Complexity | 2 |
| Total Lines | 24 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | from winrm.protocol import Protocol |
||
| 10 | class WinRMCmdAction(Action): |
||
| 11 | def run(self, host, password, command, params, username='Administrator', |
||
| 12 | port=5732, secure=True): |
||
| 13 | proto = 'https' if secure else 'http' |
||
| 14 | p = Protocol( |
||
| 15 | endpoint='%s://%s:%i/wsman' % (proto, host, port), # RFC 2732? |
||
| 16 | transport='ntlm', |
||
| 17 | username=username, |
||
| 18 | password=password, |
||
| 19 | server_cert_validation='ignore') |
||
| 20 | shell_id = p.open_shell() |
||
| 21 | std_out_logs = [] |
||
| 22 | std_err_logs = [] |
||
| 23 | |||
| 24 | # run the command |
||
| 25 | command_id = p.run_command(shell_id, command, params) |
||
| 26 | std_out, std_err, status_code = p.get_command_output(shell_id, |
||
| 27 | command_id) |
||
| 28 | std_out_logs.append(std_out) |
||
| 29 | std_err_logs.append(std_err) |
||
| 30 | p.cleanup_command(shell_id, command_id) |
||
| 31 | |||
| 32 | p.close_shell(shell_id) |
||
| 33 | return std_out_logs, std_err_logs |
||
| 34 |