-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexecuteActionList4IEM.py
More file actions
executable file
·59 lines (46 loc) · 1.72 KB
/
executeActionList4IEM.py
File metadata and controls
executable file
·59 lines (46 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import requests
import elementtree as ET
from dict2xml import dict2xml
class Action(object):
_actionTemplate = '''<BES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BES.xsd">
<SourcedFixletAction>
<SourceFixlet>
<Sitename>ActionSite</Sitename>
<FixletID>%%FixletID</FixletID>
<Action>Action1</Action>
</SourceFixlet>
<Target>
<ComputerName>%%TargetName</ComputerName>
</Target>
<Parameter Name="%%ParameterName"></Parameter>
</SourcedFixletAction>
</BES>'''
def __init__(self):
pass
@property
def actionTemplate(self):
""" get the template """
return self._actionTemplate
def actionFactory(fixletID, targetName, parameterName=pName, parameterValue=pvalue):
return _actionTemplate
action = { 'SourceFixletAction': {
'SourceFixlet': {
'Sitename' : 'ActionSite',
'FixletID' : '',
'Action' : 'Action1'
},
'Target' : {
'ComputerName' : ''
}
}
}
baseurl = 'https://localhost:52311/api/'
files = {'file': open('stopBesGather.xml', 'rb')}
r = requests.get('https://localhost:52311/api/login',verify=False,auth=('adminMO','adminmo'))
if r.status_code != 200:
print r.status_code
# issue action specified in stopBesGather.xml
r = requests.post(baseurl+'actions',verify=False,auth=('adminMO','adminmo'), data=open('stopBesGather.xml', 'rb'))
if r.status_code != 200:
print r.status_code
print '\nHeres the XML about the action that I got back: \n', r.text