"""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
-things like set up ssh keys. In addition, an Account subclass must
+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
+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
code. For no particular reason, TYPE is divided hierarchically by
maximum stack size.
"""
-import Queue
+#import Queue
import os
-import pwd
-import grp
+import pwd, grp
import threading
import logger
class Account:
def __init__(self, rec):
- logger.verbose('Initing account %s'%rec['name'])
+ logger.verbose('accounts: Initing account %s'%rec['name'])
self.name = rec['name']
self.keys = ''
self.initscriptchanged = False
@staticmethod
def create(name, vref = None): abstract
+
@staticmethod
def destroy(name): abstract
def configure(self, rec):
"""Write <rec['keys']> to my authorized_keys file."""
- logger.verbose('%s: in accounts:configure'%self.name)
+ logger.verbose('accounts: configuring %s'%self.name)
new_keys = rec['keys']
if new_keys != self.keys:
# get the unix account info
dot_ssh = os.path.join(pw_dir,'.ssh')
if not os.path.isdir(dot_ssh):
if not os.path.isdir(pw_dir):
- logger.verbose('WARNING: homedir %s does not exist for %s!'%(pw_dir,self.name))
+ logger.verbose('accounts: WARNING: homedir %s does not exist for %s!'%(pw_dir,self.name))
os.mkdir(pw_dir)
os.chown(pw_dir, uid, gid)
os.mkdir(dot_ssh)
# set self.keys to new_keys only when all of the above ops succeed
self.keys = new_keys
- logger.log('%s: installed ssh keys' % self.name)
+ logger.log('accounts: %s: installed ssh keys' % self.name)
def start(self, delay=0): pass
def stop(self): pass
def is_running(self): pass
class Worker:
+
def __init__(self, name):
self.name = name # username
self._acct = None # the account object currently associated with this worker
status = True
else:
status = False
- logger.verbose("Worker(%s): is not running" % self.name)
+ logger.verbose("accounts: Worker(%s): is not running" % self.name)
return status
def _destroy(self, curr_class):