X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plugins%2Fhostmap.py;fp=plugins%2Fhostmap.py;h=c6829cb0c284d0147f9a1daa88a1ca746cb2e483;hb=1b4f53e648b13f7629970787b6ec03387e2d966a;hp=8bd1c089a7fdf0732b7a21ff25692539763a6b76;hpb=9e596e6eb3c871ab25837903b0ed30f165d9d688;p=nodemanager.git diff --git a/plugins/hostmap.py b/plugins/hostmap.py index 8bd1c08..c6829cb 100644 --- a/plugins/hostmap.py +++ b/plugins/hostmap.py @@ -48,7 +48,8 @@ def GetSlivers(data, config=None, plc=None): if not os.path.exists(fn): continue - contents = file(fn,"r").read() + with open(fn) as f: + contents = f.read() hostmap = [] for index, entry in enumerate(tag["value"].split("\n")): @@ -84,7 +85,8 @@ def GetSlivers(data, config=None, plc=None): contents = contents + hostmap try: - file(fn, "w").write(contents) + with open(fn, "w") as f: + f.write(contents) except: logger.log_exc("hostmap (%s): failed to write %s" % (slicename, fn))