X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plugins%2Fvsys_sysctl.py;h=9be14007ce43a4fcb4e4a029b2f9ea0f7093da93;hb=HEAD;hp=3539ab1c952e0449cdd37c67477b4715331bffe9;hpb=63e92906c99bb95dd26b7f38dbfe443d53e3dad9;p=nodemanager.git diff --git a/plugins/vsys_sysctl.py b/plugins/vsys_sysctl.py index 3539ab1..9be1400 100644 --- a/plugins/vsys_sysctl.py +++ b/plugins/vsys_sysctl.py @@ -13,7 +13,7 @@ def GetSlivers(data, config=None, plc=None): """For each sliver with the vsys attribute, set the script ACL, create the vsys directory in the slice, and restart vsys.""" if 'slivers' not in data: - logger.log_missing_data("vsys.GetSlivers",'slivers') + logger.log_missing_data("vsys.GetSlivers", 'slivers') return slices = [] @@ -30,7 +30,7 @@ def GetSlivers(data, config=None, plc=None): except: logger.log("vsys_sysctl: failed to create dir %s" % dir) - (junk, key) = attribute['tagname'].split(".",1) + (junk, key) = attribute['tagname'].split(".", 1) value = str(attribute['value']) fn = os.path.join(dir, key) @@ -46,13 +46,14 @@ def GetSlivers(data, config=None, plc=None): # slice. This lets us know that we've done the sysctl. try: logger.log("vsys_sysctl: create file %s value %s" % (fn, value)) - file(fn,"w").write(value+"\n") + with open(fn, "w") as f: + f.write(value+"\n") except: logger.log("vsys_sysctl: failed to create file %s" % fn) def test_value(fn, value): try: - slice_value = file(fn,"r").readline().strip() + slice_value = file(fn, "r").readline().strip() except: slice_value = None