minor tweaks, and revert on forcing refresh_slice_vinit, this is not the problem
[nodemanager.git] / sliver_lxc.py
index b7cd45f..babac35 100644 (file)
@@ -64,18 +64,25 @@ class Sliver_LXC(Sliver_Libvirt, Initscript):
         # if a change has occured in the slice initscript, reflect this in /etc/init.d/vinit.slice
         self.refresh_slice_vinit()
 
-    def rerun_slice_vinit (self):
-        """This is called whenever the initscript code changes"""
-        # xxx - todo - not sure exactly how to:
-        # (.) invoke something in the guest
-        # (.) which options of systemctl should be used to trigger a restart
-        # should not prevent the first run from going fine hopefully
-        logger.log("WARNING: sliver_lxc.rerun_slice_vinit not implemented yet")
-
+    def rerun_slice_vinit(self):
+        """This is called at startup, and whenever the initscript code changes"""
+        logger.log("sliver_lxc.rerun_slice_vinit {}".format(self.name))
+        plain = "virsh -c lxc:/// lxc-enter-namespace --noseclabel -- {} /usr/bin/systemctl --system daemon-reload"\
+            .format(self.name)
+        command = plain.split()
+        logger.log_call(command, timeout=3)
+        plain = "virsh -c lxc:/// lxc-enter-namespace --noseclabel -- {} /usr/bin/systemctl restart vinit.service"\
+            .format(self.name)
+        command = plain.split()
+        logger.log_call(command, timeout=3)
+                
+        
     @staticmethod
     def create(name, rec=None):
-        ''' Create dirs, copy fs image, lxc_create '''
-        logger.verbose ('sliver_lxc: %s create'%(name))
+        '''
+        Create dirs, copy fs image, lxc_create
+        '''
+        logger.verbose('sliver_lxc: %s create' % name)
         conn = Sliver_Libvirt.getConnection(Sliver_LXC.TYPE)
 
         vref = rec['vref']