petrel-oss-python-sdk2 / scripts /get_serverlist.py
Weiyun1025's picture
Upload folder using huggingface_hub
2abfccb verified
raw
history blame contribute delete
No virus
845 Bytes
import commands
import numpy as np
masters = ['10.10.11.22', '10.10.12.145', '10.10.20.21', '10.1.72.101']
def parse(string):
global masters
result = []
for line in string.split('\n'):
fields = line.split('-')
ip = '.'.join(fields[2:])
if ip not in masters:
result.append(ip)
return result
if __name__ == '__main__':
output = commands.getoutput("scontrol show node | grep NodeName | awk \'{print$1}\' | awk -F = \'{print$2}\'")
print 'the set of machines in this cluster is:'
print output
serverlist = parse(output)
print 'transfer into IP address:'
print serverlist
with open('server_list.conf', 'w') as wf:
np.savetxt(wf, serverlist, delimiter='\n', fmt='%s')
wf.close()
print 'IP addresses have been written into server_list.conf'