why are we forking here? Removed fork just to write a file.
[nodemanager.git] / accounts.py
index 3711a0d..3413e9c 100644 (file)
@@ -86,16 +86,14 @@ class Account:
         if new_keys != self.keys:
             self.keys = new_keys
             dot_ssh = '/home/%s/.ssh' % self.name
-            def do_installation():
-                if not os.access(dot_ssh, os.F_OK): os.mkdir(dot_ssh)
-                os.chmod(dot_ssh, 0700)
-                tools.write_file(dot_ssh + '/authorized_keys', lambda f: f.write(new_keys))
+            if not os.access(dot_ssh, os.F_OK): os.mkdir(dot_ssh)
+            os.chmod(dot_ssh, 0700)
+            tools.write_file(dot_ssh + '/authorized_keys', lambda f: f.write(new_keys))
             logger.verbose('%s: installing ssh keys' % self.name)
-            tools.fork_as(self.name, do_installation)
 
     def start(self, delay=0): pass
     def stop(self): pass
-
+    def is_running(self): pass
 
 class Worker:
     # these semaphores are acquired before creating/destroying an account
@@ -128,7 +126,7 @@ class Worker:
             finally: self._create_sem.release()
         if not isinstance(self._acct, next_class): self._acct = next_class(rec)
         else: self._acct.configure(rec)
-        if startingup:
+        if startingup or not self.is_running():
             csd_lock.acquire()
             global cumstartdelay
             delay = cumstartdelay
@@ -147,6 +145,11 @@ class Worker:
     def stop(self): self._q.put((self._stop,))
     def _stop(self): self._acct.stop()
 
+    def is_running(self): 
+        status = self._acct.is_running()
+        if not status:  logger.verbose("Worker(%s): is not running" % self.name)
+        return status
+
     def _destroy(self, curr_class):
         self._acct = None
         if curr_class: