* Delegated slivers are refreshed on each epoc from info from PLC. Can be suspended...
[nodemanager.git] / controller.py
similarity index 68%
rename from delegate.py
rename to controller.py
index 73a0743..17268d2 100644 (file)
@@ -3,20 +3,25 @@
 import accounts
 import logger
 import tools
+from pwd import getpwnam
 
-
-class Delegate(accounts.Account):
+class Controller(accounts.Account):
     SHELL = '/usr/bin/forward_api_calls'  # tunneling shell
-    TYPE = 'delegate'
+    TYPE = 'controller.Controller'
 
     @staticmethod
     def create(name, vref = None):
-        add_shell(Delegate.SHELL)
-        logger.log_call('/usr/sbin/useradd', '-p', '*', '-s', Delegate.SHELL, name)
+        add_shell(Controller.SHELL)
+        logger.log_call('/usr/sbin/useradd', '-p', '*', '-s', Controller.SHELL, name)
 
     @staticmethod
     def destroy(name): logger.log_call('/usr/sbin/userdel', '-r', name)
 
+    def is_running(self):
+        logger.verbose("Delegate:  %s" % self.name)
+        return getpwnam(self.name)[6] == self.SHELL
+    
+
 def add_shell(shell):
     """Add <shell> to /etc/shells if it's not already there."""
     etc_shells = open('/etc/shells')