Log In | Get Help   
Home My Page Projects Code Snippets Project Openings BonFIRE VCOC Demonstration Kit
Summary Activity SCM Files Wiki
[bonfiredemokit] View of /virt-cluster/vc/hostsfile.py
[bonfiredemokit] / virt-cluster / vc / hostsfile.py Repository:
ViewVC logotype

View of /virt-cluster/vc/hostsfile.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (download) (as text) (annotate)
Mon Aug 27 11:46:35 2012 UTC (11 years, 9 months ago) by agomez
File size: 507 byte(s)
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))

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge