-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse_entities.py
More file actions
66 lines (44 loc) · 1.6 KB
/
parse_entities.py
File metadata and controls
66 lines (44 loc) · 1.6 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
import config
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
HOST = config.HOST
USERNAME = config.USERNAME
PASSWORD = config.PASSWORD
def parse_entities(response_json, entity_type):
results = []
data = response_json.get("data", [])
for item in data:
uuid = item.get("extId")
name = item.get("name")
if entity_type == "category":
name = f"{item.get('key')}:{item.get('value')}"
elif entity_type == "container":
uuid = item.get("containerExtId")
if entity_type == "pc":
software_list = item.get("config", {}).get("clusterSoftwareMap", [])
for software in software_list:
if software.get("softwareType") == "PRISM_CENTRAL":
break
else:
continue
elif entity_type == "pe":
software_list = item.get("config", {}).get("clusterSoftwareMap", [])
for software in software_list:
if software.get("softwareType") == "NOS":
break
else:
continue
results.append({
"name": name,
"uuid": uuid,
"type": entity_type
})
return results
# containerss=list_containers(HOST,USERNAME, PASSWORD)
# #print(response_json)
# subnetss=list_subnets(HOST,USERNAME, PASSWORD)
# subnets_uuid=parse_entities(subnetss,"subnet")
# print(subnets_uuid)
# print("####################")
# containers_uuid=parse_entities(containerss,"container")
# print(containers_uuid)