From: Stephen Soltesz Date: Fri, 13 Jun 2008 21:57:42 +0000 (+0000) Subject: patch to not create the /vservers/slicename/vsys directory until vuseradd has X-Git-Tag: NodeManager-1.7-12~2 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=7d5ed2e815f022cf64d1c9f21fbebd0c66a134e6;p=nodemanager.git patch to not create the /vservers/slicename/vsys directory until vuseradd has created /vservers/slicename, then report the difference so that vsys can be restarted even if the configuration files have not been movidifed. Restarting vsys will ensure that it re-reads the config file. The preferred long-term solution is for vsys to auto-read it's config files using the same/similar inotify mechanism used on the pipes. --- diff --git a/vsys.py b/vsys.py index 17b3b59..39f3435 100644 --- a/vsys.py +++ b/vsys.py @@ -21,6 +21,7 @@ def GetSlivers(data): for script in touchAcls(): scripts[script] = [] # slices that need to be written to the conf slices = [] + _restart = False # Parse attributes and update dict of scripts for sliver in data['slivers']: for attribute in sliver['attributes']: @@ -29,7 +30,7 @@ def GetSlivers(data): # add to conf slices.append(sliver['name']) # As the name implies, when we find an attribute, we - createVsysDir(sliver['name']) + _restart = createVsysDir(sliver['name']) # add it to our list of slivers that need vsys if attribute['value'] in scripts.keys(): scripts[attribute['value']].append(sliver['name']) @@ -37,15 +38,18 @@ def GetSlivers(data): # Write the conf writeConf(slices, parseConf()) # Write out the ACLs - if writeAcls(scripts, parseAcls()): + if writeAcls(scripts, parseAcls()) or _restart: logger.log("vsys: restarting vsys service") os.system("/etc/init.d/vsys restart") def createVsysDir(sliver): '''Create /vsys directory in slice. Update vsys conf file.''' - try: os.makedirs("/vservers/%s/vsys" % sliver) - except OSError: pass + try: + os.mkdir("/vservers/%s/vsys" % sliver) + return True + except OSError: + return False def touchAcls():