/
redfish_exe.py
executable file
·57 lines (47 loc) · 1.37 KB
/
redfish_exe.py
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
#!/usr/bin/python3
import argparse
from Red_lib.config import CONF
import os
import re
from datetime import datetime
from urllib.request import urlopen
import json
from time import sleep
from Red_lib.loglib import logger
from Red_lib.get_nodes import GET_NODE, URL_REQUEST
VERSION = '1.0.0'
host = "10.204.29.244"
#url = "/redfish/v1/Systems/Default string"
url = "/redfish/v1"
def compare_url(last_url=None,new_url=None):
diff_url_str=""
if len(last_url)<len(new_url):
for url in list(set(new_url)-set(last_url)):
diff_url_str+="\n\t"+url
msg="New node has been found:<hl>{0:s}</hl>".format(diff_url_str)
else:
for url in list(set(last_url)-set(new_url)):
diff_url_str+="\n\t"+url
msg="Missed node:<hl>{0:s}</hl>".format(diff_url_str)
logger.warning(msg)
def main():
for i in range(CONF.MAIN.cycle):
msg="SCAN ALL THE NODES IN CYCLE: {0:d}".format(i)
logger.info(msg)
get_node=GET_NODE(host,CONF.REST.client_app_ver,CONF.REST.bind_port)
get_node.scan_node()
new_url=get_node.url_list
if i!=0:
if last_url!=new_url:
compare_url(last_url,new_url)
last_url=new_url
if CONF.CLI.time_to_stop:
if datetime.now()>datetime.strptime(CONF.CLI.time_to_stop,\
'%Y-%m-%d %H:%M:%S'):
break
#input("Press Enter to continue...")
msg='Stop test on {0}, cycle {1}'.format(datetime.now(),(i+1))
logger.info(msg)
if __name__=="__main__":
main()
#pass