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

LockdownWinRMAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 16 2
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 {'stdout': out}
27