+
+
+# before shutting down slivers, it is safe to first remove them from vsys's scope
+# so that we are sure that no dangling open file remains
+# this will also stop vsys if needed (in which case it return True to tell caller to restart vsys once done)
+def removeSliverFromVsys (sliver):
+ current_slivers=parseConf()
+ new_slivers= [ s for s in current_slivers if s != sliver ]
+ if writeConf (current_slivers, new_slivers):
+ stopService()
+ trashVsysHandleInSliver (sliver)
+ return True
+ else:
+ logger.log("vsys.removeSliverFromConf: no need to remove %s"%sliver)
+ return False
+
+def trashVsysHandleInSliver (sliver):
+ slice_vsys_area = "/vservers/%s/vsys"%sliver
+ if not os.path.exists(slice_vsys_area):
+ logger.log("vsys.trashVsysHandleInSliver: no action needed, %s not found"%slice_vsys_area)
+ return
+ retcod=subprocess.call([ 'rm', '-rf' , slice_vsys_area])
+ logger.log ("vsys.trashVsysHandleInSliver: Removed %s (retcod=%s)"%(slice_vsys_area,retcod))