-Copyright 2008 Princeton University
+Copyright 2009 Princeton University
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
#!/usr/bin/python
#
# Test script for obtaining a node session key. Usually, the Boot
-# Manager obtains it, then writes it to /etc/planetlab/session. To
-# generate a node key for a node, execute:
-#
-# AdmGenerateNodeConfFile(node_id)
+# Manager obtains it, then writes it to /etc/planetlab/session.
#
# Mark Huang <mlhuang@cs.princeton.edu>
# Copyright (C) 2006 The Trustees of Princeton University
pickle.dump((version, slices, deaddb), f)
f.close()
+
def getDefaults(nmdbcopy):
'''
Get defaults from default slice's slice attributes.
status = False
return status
+
def allOff():
"""
Turn off all slice HTBs
lock = threading.Event()
def run():
- """When run as a thread, wait for event, lock db, deep copy it, release it, run bwmon.GetSlivers(), then go back to waiting."""
+ """
+ When run as a thread, wait for event, lock db, deep copy it, release it,
+ run bwmon.GetSlivers(), then go back to waiting.
+ """
logger.log("bwmon: Thread started", 2)
while True:
lock.wait()
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')
else:
InitNodeLimit(data)
InitI2(plc, data)
-
InitNAT(plc, data)
+
def InitNodeLimit(data):
if not 'networks' in data: return
setup(
py_modules=[
- 'accounts',
- 'api',
- 'api_calls',
- 'conf_files',
- 'config',
- 'curlwrapper',
- 'database',
- 'delegate',
- 'logger',
- 'net',
- 'nm',
- 'plcapi',
- 'safexmlrpc',
- 'sliver_vs',
- 'sm',
- 'ticket',
- 'tools',
- 'bwmon',
- 'iptables',
- ],
+ 'accounts',
+ 'api',
+ 'api_calls',
+ 'bwmon',
+ 'conf_files',
+ 'config',
+ 'controller',
+ 'curlwrapper',
+ 'database',
+ 'iptables',
+ 'logger',
+ 'net',
+ 'nm',
+ 'plcapi',
+ 'safexmlrpc',
+ 'sliver_vs',
+ 'sm',
+ 'ticket',
+ 'tools',
+ ],
scripts = [
- 'forward_api_calls',
- ],
- packages = [
- 'plugins',
- ],
+ 'forward_api_calls',
+ ],
+ packages =[
+ 'plugins',
+ ],
)
import api
import api_calls
import database
-import delegate
+import controller
import logger
import sliver_vs
import string,re
keys = rec.pop('keys')
rec.setdefault('keys', '\n'.join([key_struct['key'] for key_struct in keys]))
+ ## 'Type' isn't returned by GetSlivers() for whatever reason. We're overloading
+ ## instantiation here, but i suppose its the ssame thing when you think about it. -FA
# Handle nm controller here
- rec.setdefault('type', attr_dict.get('type', 'sliver.VServer'))
- if rec['instantiation'] == 'nm-controller':
- # type isn't returned by GetSlivers() for whatever reason. We're overloading
- # instantiation here, but i suppose its the ssame thing when you think about it. -FA
- rec['type'] = 'delegate'
+ if rec['instantiation'].lower() == 'nm-controller':
+ rec.setdefault('type', attr_dict.get('type', 'controller.Controller'))
+ else:
+ rec.setdefault('type', attr_dict.get('type', 'sliver.VServer'))
# set the vserver reference. If none, set to default.
rec.setdefault('vref', attr_dict.get('vref', 'default'))
database.db.deliver_record(rec)
if fullupdate: database.db.set_min_timestamp(data['timestamp'])
+ # slivers are created here.
database.db.sync()
accounts.Startingup = False
DEFAULT_ALLOCATION[resname]=default_amt
accounts.register_class(sliver_vs.Sliver_VS)
- accounts.register_class(delegate.Delegate)
+ accounts.register_class(controller.Controller)
accounts.Startingup = options.startup
database.start()
api_calls.deliver_ticket = deliver_ticket