--- virt-cluster/vc/hostsfile.py 2012/08/30 12:48:07 9 +++ virt-cluster/vc/hostsfile.py 2012/08/31 10:40:38 10 @@ -1,32 +1,32 @@ -# -# BonFIRE Virtual Clusters on Federated Clouds Demonstration Kit -# -# Copyright (c) Fundacion Centro Tecnologico de Supercomputacion de Galicia 2012 -# -# License GPL Version 3 -# -# The research leading to these results has received funding from -# the European Community's Seventh Frameqork Programme (FP7/2007-2013) -# under agreement number 257386 -# -# This software is provided with ABSOLUTELY NO WARRANTY -# -def load(file_path): - hosts = {} - with open(file_path) as file: - for line in file: - line = line.strip() - if not line or line.startswith('#'): - continue - elements = line.split() - hosts[elements[0]] = elements[1:] - return hosts - -def store(file_path,hosts): - output = "\n".join([ " ".join(list(host)) for host in hosts ]) + "\n" - with open(file_path,'w') as file: - file.write(output) - -def append(file_path,ip,hostname): - with open(file_path,'a') as file: - file.write("\n%s %s\n" % (ip,hostname)) +# +# BonFIRE Virtual Clusters on Federated Clouds Demonstration Kit +# +# Copyright (c) Fundacion Centro Tecnologico de Supercomputacion de Galicia 2012 +# +# License GPL Version 3 +# +# The research leading to these results has received funding from +# the European Community's Seventh Framework Programme (FP7/2007-2013) +# under agreement number 257386 +# +# This software is provided with ABSOLUTELY NO WARRANTY +# +def load(file_path): + hosts = {} + with open(file_path) as file: + for line in file: + line = line.strip() + if not line or line.startswith('#'): + continue + elements = line.split() + hosts[elements[0]] = elements[1:] + return hosts + +def store(file_path,hosts): + output = "\n".join([ " ".join(list(host)) for host in hosts ]) + "\n" + with open(file_path,'w') as file: + file.write(output) + +def append(file_path,ip,hostname): + with open(file_path,'a') as file: + file.write("\n%s %s\n" % (ip,hostname))