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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10 - (view) (download) (as text)

1 : agomez 10 #
2 :     # BonFIRE Virtual Clusters on Federated Clouds Demonstration Kit
3 :     #
4 :     # Copyright (c) Fundacion Centro Tecnologico de Supercomputacion de Galicia 2012
5 :     #
6 :     # License GPL Version 3
7 :     #
8 :     # The research leading to these results has received funding from
9 :     # the European Community's Seventh Framework Programme (FP7/2007-2013)
10 :     # under agreement number 257386
11 :     #
12 :     # This software is provided with ABSOLUTELY NO WARRANTY
13 :     #
14 :     def load(file_path):
15 :     hosts = {}
16 :     with open(file_path) as file:
17 :     for line in file:
18 :     line = line.strip()
19 :     if not line or line.startswith('#'):
20 :     continue
21 :     elements = line.split()
22 :     hosts[elements[0]] = elements[1:]
23 :     return hosts
24 :    
25 :     def store(file_path,hosts):
26 :     output = "\n".join([ " ".join(list(host)) for host in hosts ]) + "\n"
27 :     with open(file_path,'w') as file:
28 :     file.write(output)
29 :    
30 :     def append(file_path,ip,hostname):
31 :     with open(file_path,'a') as file:
32 :     file.write("\n%s %s\n" % (ip,hostname))

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

Powered By FusionForge