Completed
Pull Request — master (#499)
by Anthony
03:02
created

LockdownWinRMAction.run()   A

Complexity

Conditions 2

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
1
from pywinexe.api import cmd as run_cmd
2
3
from st2actions.runners.pythonrunner import Action
4
5
__all__ = [
6
    'LockdownWinRMAction'
7
]
8
9
10
class LockdownWinRMAction(Action):
11
    def run(self, host, password, username='Administrator'):
12
        """
13
        Setup WinRM on a remote node
14
        """
15
        cmds = [
16
            "winrm set winrm/config/service/auth @{Basic=\"false\"}",
17
            "winrm set winrm/config/service @{AllowUnencrypted=\"false\"}"
18
        ]
19
        out = [
20
            run_cmd(
21
                cmd,
22
                args=[],
23
                user=username,
24
                password=password,
25
                host=host) for cmd in cmds]
26
        return out
27