name_worker_lock = threading.Lock()
name_worker = {}
+def allpwents():
+ return [pw_ent for pw_ent in pwd.getpwall() if pw_ent[6] in shell_acct_class]
+
def all():
"""Return the names of all accounts on the system with recognized shells."""
- return [pw_ent[0] for pw_ent in pwd.getpwall() if pw_ent[6] in shell_acct_class]
+ return [pw_ent[0] for pw_ent in allpwents()]
def get(name):
"""Return the worker object for a particular username. If no such object exists, create it first."""
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))
logger.log('%s: installing ssh keys' % self.name)
tools.fork_as(self.name, do_installation)
import accounts
import database
import logger
+import sliver_vs
import ticket
import tools
except Exception, err:
raise xmlrpclib.Fault(102, 'Ticket error: ' + str(err))
+@export_to_api(0)
+def GetXIDs():
+ """GetXIDs(): return an dictionary mapping slice names to XIDs"""
+ return dict([(pwent[0], pwent[2]) for pwent in pwd.getpwall() if pwent[6] == sliver_vs.Sliver_VS.SHELL])
+
+@export_to_api(0)
+def GetSSHKeys():
+ """GetSSHKeys(): return an dictionary mapping slice names to SSH keys"""
+ keydict = {}
+ for rec in database.db.itervalues():
+ if 'keys' in rec:
+ keydict[rec['name']] = rec['keys']
+ return keydict
+
@export_to_api(1)
def Create(rec):
"""Create(sliver_name): create a non-PLC-instantiated sliver"""
ucred = self.request.getsockopt(socket.SOL_SOCKET, SO_PEERCRED, sizeof_struct_ucred)
xid = struct.unpack('3i', ucred)[2]
caller_name = pwd.getpwuid(xid)[0]
- if method_name not in ('Help', 'Ticket'):
+ if method_name not in ('Help', 'Ticket', 'GetXIDs', 'GetSSHKeys'):
target_name = args[0]
target_rec = database.db.get(target_name)
if not (target_rec and target_rec['type'].startswith('sliver.')): raise xmlrpclib.Fault(102, 'Invalid argument: the first argument must be a sliver name.')
# We enforce minimum allocations to keep the clueless from hosing their slivers.
# Disallow disk loans because there's currently no way to punish slivers over quota.
-MINIMUM_ALLOCATION = {'cpu_min': 0, 'cpu_share': 16, 'net_min_rate': 0, 'net_max_rate': 8, 'net_i2_min_rate': 0, 'net_i2_max_rate': 8, 'net_share': 1}
+MINIMUM_ALLOCATION = {'cpu_min': 0, 'cpu_share': 32, 'net_min_rate': 0, 'net_max_rate': 8, 'net_i2_min_rate': 0, 'net_i2_max_rate': 8, 'net_share': 1}
LOANABLE_RESOURCES = MINIMUM_ALLOCATION.keys()
DB_FILE = '/root/sliver_mgr_db.pickle'