X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=accounts.py;h=d540368deb21b2643fe8866e0986c40f16843775;hb=737532f28237ed08d3895b5912866476f909e04f;hp=6bffdbe8ae725061ee626f7cf08245b96910052f;hpb=28843cfb70c54f24a08aa32495eac70964c8b1f0;p=nodemanager.git diff --git a/accounts.py b/accounts.py index 6bffdbe..d540368 100644 --- a/accounts.py +++ b/accounts.py @@ -1,8 +1,8 @@ """Functionality common to all account classes. -Each subclass of Account must provide five methods: create() and -destroy(), which are static; configure(), start(), and stop(), which -are not. configure(), which takes a record as its only argument, does +Each subclass of Account must provide 6 methods: create() and +destroy(), which are static; configure(), is_running(), start(), and stop(), +which are not. configure() takes a record as its only argument, and does things like set up ssh keys. In addition, an Account subclass must provide static member variables SHELL, which contains the unique shell that it uses; and TYPE, a string that is used by the account creation @@ -41,7 +41,6 @@ def register_class(acct_class): # private account name -> worker object association and associated lock name_worker_lock = threading.Lock() -# dict of account_name: name_worker = {} def allpwents(): @@ -55,9 +54,7 @@ def get(name): """Return the worker object for a particular username. If no such object exists, create it first.""" name_worker_lock.acquire() try: - if name not in name_worker: - logger.verbose("Accounts:get(%s) new Worker" % name) - name_worker[name] = Worker(name) + if name not in name_worker: name_worker[name] = Worker(name) return name_worker[name] finally: name_worker_lock.release() @@ -127,7 +124,7 @@ class Worker: def stop(self): self._acct.stop() def is_running(self): - if self._acct.is_running(): + if (self._acct != None) and self._acct.is_running(): status = True else: status = False