-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtemRest-cleanup.py
More file actions
executable file
·86 lines (76 loc) · 2.49 KB
/
temRest-cleanup.py
File metadata and controls
executable file
·86 lines (76 loc) · 2.49 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import requests
import xml.etree.ElementTree as ET
baseurl = 'https://localhost:52311/api/'
# So, first we need to log into the system....
r = requests.get('https://localhost:52311/api/login',verify=False,auth=('adminMO','adminmo'))
if r.status_code != 200:
print r.status_code
else:
print('temRest.py: too bad sucka! - [failed on login]: %s')
# Let's read all the master-actionsite fixlets....
r = requests.get(baseurl+'fixlets/master',verify=False,auth=('adminMO','adminmo'))
if r.status_code != 200:
print r.status_code
else:
print('temRest.py: too bad sucka! - [failed to read the fixlet stream: %s')
root = ET.fromstring(r.text)
#for child in root:
# print child.tag, child.attrib
i = []
n = []
print 'starting search in results'
for fixlet in root.findall('Fixlet'):
n.append(fixlet.find('Name').text)
i.append(fixlet.find('ID').text)
print 'creating dictionary'
d = dict(zip(i,n))
print 'temRest.py: will try to print the resulting dictionary:'
for key in iter(d):
print key,d[key]
#for name in root.iter('Name'):
# print name.attrib
#
#r = requests.get('http://localhost:52311/api/fixlet/master/7217',verify=False,auth=('adminMO','adminmo'))
#if r.status_code == 200:
# print(r.text)
#else:
# print('too bad sucka: %s')
#
#files = {'file': open('stopBesGather.xml', 'rb')}
#url = 'http://localhost:52311/api/actions'
#r = requests.post(url, verify=False,auth=('adminMO','adminmo'), files=files)
#print( r.text )
#
#prototype =
#"""<?xml version="1.0" encoding="UTF-8"?>
#<BES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BES.xsd">
#<SourcedFixletAction>
#<SourceFixlet>
#<Sitename>TestSite</Sitename>
#<FixletID>83</FixletID>
#<Action>Action1</Action>
#</SourceFixlet>
#<Target>
#<ComputerName>bhobbs-db</ComputerName>
#</Target>
#<Parameter Name="_BESClient_EMsg_Detail">1000</Parameter>
#</SourcedFixletAction>
#</BES>"""
#
#prelude = """
#<?xml version="1.0" encoding="UTF-8"?>
#<BES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BES.xsd">
# <SingleAction>
# <Title><![CDATA[Stop two Services]]></Title>
# <Relevance><![CDATA[false]]></Relevance>
# <ActionScript MIMEType="application/x-sh"><![CDATA["""
#
#postlude = """
#>]]></ActionScript>
# <SuccessCriteria Option="RunToCompletion"/>
# <Target>
# <ComputerName>1</ComputerName>
# </Target>
# </SingleAction>
#</BES>"""
#