Merge branch 'master' into lxc_devel
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Fri, 15 Jun 2012 14:11:50 +0000 (17:11 +0300)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Fri, 15 Jun 2012 14:11:50 +0000 (17:11 +0300)
Conflicts:
NodeManager.spec
api.py
slivermanager.py

28 files changed:
Makefile
NodeManager.spec
account.py [moved from accounts.py with 81% similarity]
api.py
api_calls.py
conf_files.py
controller.py
coresched.py
database.py
forward_api_calls.c
initscripts/conf_files
initscripts/fuse-pl
initscripts/nm
iptables.py
net.py
nodemanager.py
plugins/codemux.py
plugins/rawdisk.py
plugins/reservation.py
plugins/sfagids.py
plugins/specialaccounts.py
plugins/vsys.py
plugins/vsys_privs.py
setup.py
sliver_vs.py
slivermanager.py
ticket.py
tools.py

index 08c3acf..c9e0d91 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -68,7 +68,7 @@ endif
 TESTMASTER ?= testmaster.onelab.eu
 
 ifdef BUILD
-KEYURL:=root@$(TESTMASTER):$(BUILD)/keys/key1.rsa
+KEYURL:=root@$(TESTMASTER):$(BUILD)/keys/key_admin.rsa
 endif
 
 key: $(NODE).key.rsa
index fd038c6..d0e7f93 100644 (file)
@@ -142,8 +142,11 @@ rm -rf $RPM_BUILD_ROOT
 - first working draft for dealing with libvirt/lxc on f16 nodes
 - not expected to work with mainline nodes (use 2.0 for that for now)
 
-* Fri Jan 13 2012 Marco Yuen <marcoy@cs.princeton.edu> - nodemanager-2.0-34
-- Install bwlimit.py to the python site directory.
+* Sun Jun 03 2012 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - nodemanager-2.0-36
+- /var/log/nodemanager shows duration of mainloop
+
+* Fri Apr 13 2012 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - nodemanager-2.0-35
+- remove Requires to deprecated vserver-* rpms, use sliceimage-* instead
 
 * Fri Dec 09 2011 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - nodemanager-2.0-34
 - Added memory scheduling to core scheduler
similarity index 81%
rename from accounts.py
rename to account.py
index 2f3bb32..ac02312 100644 (file)
@@ -71,7 +71,7 @@ def get(name):
 
 class Account:
     def __init__(self, rec):
-        logger.verbose('accounts: Initing account %s'%rec['name'])
+        logger.verbose('account: Initing account %s'%rec['name'])
         self.name = rec['name']
         self.keys = ''
         self.configure(rec)
@@ -84,7 +84,7 @@ class Account:
 
     def configure(self, rec):
         """Write <rec['keys']> to my authorized_keys file."""
-        logger.verbose('accounts: configuring %s'%self.name)
+        logger.verbose('account: configuring %s'%self.name)
         new_keys = rec['keys']
         if new_keys != self.keys:
             # get the unix account info
@@ -98,7 +98,7 @@ class Account:
             dot_ssh = os.path.join(pw_dir,'.ssh')
             if not os.path.isdir(dot_ssh):
                 if not os.path.isdir(pw_dir):
-                    logger.verbose('accounts: WARNING: homedir %s does not exist for %s!'%(pw_dir,self.name))
+                    logger.verbose('account: 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)
@@ -115,7 +115,7 @@ class Account:
             # set self.keys to new_keys only when all of the above ops succeed
             self.keys = new_keys
 
-            logger.log('accounts: %s: installed ssh keys' % self.name)
+            logger.log('account: %s: installed ssh keys' % self.name)
 
     def start(self, delay=0): pass
     def stop(self): pass
@@ -140,7 +140,7 @@ If still valid, check if running and configure/start if not."""
             try: next_class.create(self.name, rec)
             finally: create_sem.release()
         if not isinstance(self._acct, next_class): self._acct = next_class(rec)
-        logger.verbose("accounts.ensure_created: %s, running=%r"%(self.name,self.is_running()))
+        logger.verbose("account.ensure_created: %s, running=%r"%(self.name,self.is_running()))
 
         # reservation_alive is set on reervable nodes, and its value is a boolean
         if 'reservation_alive' in rec:
@@ -176,7 +176,7 @@ If still valid, check if running and configure/start if not."""
             status = True
         else:
             status = False
-            logger.verbose("accounts: Worker(%s): is not running" % self.name)
+            logger.verbose("account: Worker(%s): is not running" % self.name)
         return status
 
     def _destroy(self, curr_class):
@@ -190,3 +190,24 @@ If still valid, check if running and configure/start if not."""
         try: shell = pwd.getpwnam(self.name)[6]
         except KeyError: return None
         return shell_acct_class[shell]
+
+    # bind mount root side dir to sliver side
+    # needs to be done before sliver starts, in the vserver case at least
+    def expose_ssh_dir (self):
+        try:
+            root_ssh="/home/%s/.ssh"%self.name
+            sliver_ssh="/vservers/%s/home/%s/.ssh"%(self.name,self.name)
+            # any of both might not exist yet
+            for path in [root_ssh,sliver_ssh]:
+                if not os.path.exists (path):
+                    os.mkdir(path)
+                if not os.path.isdir (path):
+                    raise Exception
+            mounts=file('/proc/mounts').read()
+            if mounts.find(sliver_ssh)<0:
+                # xxx perform mount
+                subprocess.call("mount --bind -o ro %s %s"%(root_ssh,sliver_ssh),shell=True)
+                logger.log("expose_ssh_dir: %s mounted into slice %s"%(root_ssh,self.name))
+        except:
+            logger.log_exc("expose_ssh_dir with slice %s failed"%self.name)
+
diff --git a/api.py b/api.py
index 2f94d23..7b5ab95 100644 (file)
--- a/api.py
+++ b/api.py
@@ -20,9 +20,7 @@ import threading
 import xmlrpclib
 import sys
 
-import accounts
 import database
-import ticket
 import tools
 from api_calls import *
 import logger
index 4a5558e..084bf66 100644 (file)
@@ -27,7 +27,7 @@ except:
     def Mixed(a = None, b = None, c = None): pass
 
 
-import accounts
+import account
 import logger
 
 # TODO: These try/excepts are a hack to allow doc/DocBookLocal.py to
@@ -171,7 +171,7 @@ def Create(sliver_name):
     """Create a non-PLC-instantiated sliver"""
     rec = sliver_name
     if rec['instantiation'] == 'delegated':
-        accounts.get(rec['name']).ensure_created(rec)
+        account.get(rec['name']).ensure_created(rec)
         logger.log("api_calls: Create %s"%rec['name'])
     else:
         raise Exception, "Only PLC can create non delegated slivers."
@@ -185,7 +185,7 @@ def Destroy(sliver_name):
     """Destroy a non-PLC-instantiated sliver"""
     rec = sliver_name
     if rec['instantiation'] == 'delegated':
-        accounts.get(rec['name']).ensure_destroyed()
+        account.get(rec['name']).ensure_destroyed()
         logger.log("api_calls: Destroy %s"%rec['name'])
     else:
         raise Exception, "Only PLC can destroy non delegated slivers."
@@ -198,7 +198,7 @@ def Destroy(sliver_name):
 def Start(sliver_name):
     """Configure and start sliver."""
     rec = sliver_name
-    accounts.get(rec['name']).start(rec)
+    account.get(rec['name']).start(rec)
     logger.log("api_calls: Start %s"%rec['name'])
 
 
@@ -209,7 +209,7 @@ def Start(sliver_name):
 def Stop(sliver_name):
     """Kill all processes belonging to the specified sliver"""
     rec = sliver_name
-    accounts.get(rec['name']).stop()
+    account.get(rec['name']).stop()
     logger.log("api_calls: Stop %s"%rec['name'])
 
 
@@ -220,9 +220,9 @@ def Stop(sliver_name):
 def ReCreate(sliver_name):
     """Stop, Destroy, Create, Start sliver in order to reinstall it."""
     rec = sliver_name
-    accounts.get(rec['name']).stop()
-    accounts.get(rec['name']).ensure_created(rec)
-    accounts.get(rec['name']).start(rec)
+    account.get(rec['name']).stop()
+    account.get(rec['name']).ensure_created(rec)
+    account.get(rec['name']).start(rec)
     logger.log("api_calls: ReCreate %s"%rec['name'])
 
 @export_to_docbook(roles=['nm-controller', 'self'],
index c16639f..252c795 100644 (file)
@@ -1,6 +1,3 @@
-# $Id$
-# $URL$
-
 """configuration files"""
 
 import grp
index 9979370..c66ddff 100644 (file)
@@ -7,9 +7,9 @@ from grp import getgrnam
 
 import logger
 import tools
-import accounts
+import account
 
-class Controller(accounts.Account):
+class Controller(account.Account):
     SHELL = '/usr/bin/forward_api_calls'  # tunneling shell
     TYPE = 'controller.Controller'
 
index 7c91fba..ff2443e 100644 (file)
@@ -1,6 +1,3 @@
-# $Id$
-# $URL$
-
 """Whole core scheduling
 
 """
index 020fd25..96664af 100644 (file)
@@ -17,7 +17,7 @@ import cPickle
 import threading
 import time
 
-import accounts
+import account
 import coresched
 import logger
 import tools
@@ -127,16 +127,16 @@ It may be necessary in the future to do something smarter."""
 
         # create and destroy accounts as needed
         logger.verbose("database: sync : fetching accounts")
-        existing_acct_names = accounts.all()
+        existing_acct_names = account.all()
         for name in existing_acct_names:
             if name not in self:
                 logger.verbose("database: sync : ensure_destroy'ing %s"%name)
-                accounts.get(name).ensure_destroyed()
+                account.get(name).ensure_destroyed()
         for name, rec in self.iteritems():
             # protect this; if anything fails for a given sliver
             # we still need the other ones to be handled
             try:
-                sliver = accounts.get(name)
+                sliver = account.get(name)
                 logger.verbose("database: sync : looping on %s (shell account class from pwd %s)" %(name,sliver._get_class()))
                 # Make sure we refresh accounts that are running
                 if rec['instantiation'] == 'plc-instantiated':
index 98fc01d..9e2d2bb 100644 (file)
@@ -1,7 +1,4 @@
 /* 
- * $Id$
- * $URL$
- *
  * forward_api_calls.c: forward XMLRPC calls to the Node Manager
  * Used as a shell, this code works in tandem with sshd
  * to allow authenticated remote access to a localhost-only service.
index 1b85817..cbf27bf 100644 (file)
@@ -1,14 +1,10 @@
 #!/bin/bash
 #
-# $Id$
-# $URL$
-#
 # conf_files       Updates node configuration files at startup
 #
 # chkconfig: 3 20 80
 # description: Updates node configuration files at startup
 #
-# $Id$
 
 # Source function library.
 . /etc/init.d/functions
index e64d53c..9336d98 100644 (file)
@@ -1,14 +1,10 @@
 #!/bin/bash
 #
-# $Id$
-# $URL$
-#
 # fuse-pl      Start FUSE support on PlanetLab
 #
 # chkconfig: 3 87 27
 # description: Start FUSE support on PlanetLab
 #
-# $Id$
 
 # Source function library.
 . /etc/init.d/functions
index 6c41ffc..13f30ed 100755 (executable)
@@ -1,8 +1,5 @@
 #!/bin/bash
 #
-# $Id$
-# $URL$
-#
 # nm       Starts and stops Node Manager daemon
 #
 # chkconfig: 3 97 26
index 3bcd252..e17be94 100644 (file)
@@ -1,10 +1,6 @@
 #!/usr/bin/python -tt
 #
-# $Id$
-# $URL$
-#
 # Author: Daniel Hokka Zakrisson <daniel@hozac.com>
-# $Id$
 
 import os
 import subprocess
diff --git a/net.py b/net.py
index f67ec78..100720c 100644 (file)
--- a/net.py
+++ b/net.py
@@ -1,6 +1,3 @@
-# $Id$
-# $URL$
-
 """network configuration"""
 
 # system provided modules
index 68a8be4..8b2c6f6 100755 (executable)
@@ -238,10 +238,13 @@ If this is not the case, please remove the pid file %s. -- exiting""" % (other_p
 
             while True:
             # Main nodemanager Loop
+                work_beg=time.time()
                 logger.log('nodemanager: mainloop - calling GetSlivers - period=%d random=%d'%(iperiod,irandom))
                 self.GetSlivers(config, plc)
                 delay=iperiod + random.randrange(0,irandom)
-                logger.log('nodemanager: mainloop - sleeping for %d s'%delay)
+                work_end=time.time()
+                work_duration=int(work_end-work_beg)
+                logger.log('nodemanager: mainloop has worked for %s s - sleeping for %d s'%(work_duration,delay))
                 time.sleep(delay)
         except: logger.log_exc("nodemanager: failed in run")
 
index c3a6a8f..7f2200d 100644 (file)
@@ -1,6 +1,3 @@
-# $Id$
-# $URL$
-
 """Codemux configurator.  Monitors slice attributes and configures CoDemux to mux port 80 based on HOST field in HTTP request.  Forwards to localhost port belonging to configured slice."""
 
 import logger
index 6d6e0f0..f64affe 100644 (file)
@@ -1,9 +1,6 @@
 #!/usr/bin/python -tt
 # vim:set ts=4 sw=4 expandtab:
 #
-# $Id$
-# $URL$
-#
 # NodeManager plugin to support mapping unused raw disks into a slice
 # that has the rawdisk sliver tag
 
index 70c6ddf..d873835 100644 (file)
@@ -11,7 +11,7 @@ import time
 import threading
 
 import logger
-import accounts
+import account
 import database
 
 # there is an implicit assumption that this triggers after slicemanager
@@ -227,15 +227,15 @@ class reservation:
 
     def is_running (self, slicename):
         try:
-            return accounts.get(slicename).is_running()
+            return account.get(slicename).is_running()
         except:
             return False
 
-    # quick an d dirty - this does not obey the accounts/sliver_vs/controller hierarchy
+    # quick an d dirty - this does not obey the account/sliver_vs/controller hierarchy
     def suspend_slice(self, slicename):
         logger.log('reservation: Suspending slice %s'%(slicename))
         self.debug_box('before suspending',slicename)
-        worker=accounts.get(slicename)
+        worker=account.get(slicename)
         try:
             logger.log("reservation: Located worker object %r"%worker)
             worker.stop()
@@ -264,7 +264,7 @@ class reservation:
     def restart_slice(self, slicename):
         logger.log('reservation: Restarting slice %s'%(slicename))
         self.debug_box('before restarting',slicename)
-        worker=accounts.get(slicename)
+        worker=account.get(slicename)
         try:
             # dig in self.data to retrieve corresponding rec
             slivers = [ sliver for sliver in self.data['slivers'] if sliver['name']==slicename ]
index 2723a7a..21ea581 100644 (file)
@@ -1,9 +1,6 @@
 #!/usr/bin/python -tt
 # vim:set ts=4 sw=4 expandtab:
 #
-# $Id$
-# $URL$
-#
 # NodeManager plugin for installing SFA GID's in slivers
 # 
 
index f3af8bc..2cbda58 100644 (file)
@@ -1,8 +1,6 @@
 #!/usr/bin/python -tt
 # vim:set ts=4 sw=4 expandtab:
 #
-# $Id$
-# $URL$
 #
 # NodeManager plugin to create special accounts
 
index b836dc5..8d4f34c 100644 (file)
@@ -1,6 +1,3 @@
-# $Id$
-# $URL$
-
 """vsys configurator.  Maintains ACLs and script pipes inside vservers based on slice attributes."""
 
 import logger
index af2b739..01ab283 100755 (executable)
@@ -1,6 +1,3 @@
-# $Id$
-# $URL$
-
 """
 vsys sub-configurator.  Maintains configuration parameters associated with vsys scripts.
 All slice attributes with the prefix vsys_ are written into configuration files on the
index 379fd46..082e565 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -1,21 +1,16 @@
 #!/usr/bin/python
 #
-# $Id$
-# $URL$
-#
 # Setup script for the Node Manager application
 #
 # Mark Huang <mlhuang@cs.princeton.edu>
 # Copyright (C) 2006 The Trustees of Princeton University
 #
-# $Id$
-#
 
 from distutils.core import setup, Extension
 
 setup(
     py_modules=[
-        'accounts',
+        'account',
         'api',
         'api_calls',
         'bwmon',
index 2febb37..9afbe68 100644 (file)
@@ -29,7 +29,7 @@ import subprocess
 # the util-vserver-pl module
 import vserver
 
-import accounts
+import account
 import logger
 import tools
 
@@ -45,7 +45,7 @@ for rlimit in vserver.RLIMITS.keys():
     DEFAULT_ALLOCATION["%s_soft"%rlim]=KEEP_LIMIT
     DEFAULT_ALLOCATION["%s_hard"%rlim]=KEEP_LIMIT
 
-class Sliver_VS(accounts.Account, vserver.VServer):
+class Sliver_VS(account.Account, vserver.VServer):
     """This class wraps vserver.VServer to make its interface closer to what we need."""
 
     SHELL = '/bin/vsh'
@@ -150,7 +150,7 @@ class Sliver_VS(accounts.Account, vserver.VServer):
             #self.initscriptchanged = True
             self.refresh_slice_vinit()
 
-        accounts.Account.configure(self, rec)  # install ssh keys
+        account.Account.configure(self, rec)  # install ssh keys
 
     # unconditionnally install and enable the generic vinit script
     # mimicking chkconfig for enabling the generic vinit script
@@ -194,26 +194,6 @@ class Sliver_VS(accounts.Account, vserver.VServer):
             else:
                 logger.log("vsliver_vs: %s: Removed obsolete initscript %s"%(self.name,sliver_initscript))
 
-    # bind mount root side dir to sliver side
-    # needs to be done before sliver starts
-    def expose_ssh_dir (self):
-        try:
-            root_ssh="/home/%s/.ssh"%self.name
-            sliver_ssh="/vservers/%s/home/%s/.ssh"%(self.name,self.name)
-            # any of both might not exist yet
-            for path in [root_ssh,sliver_ssh]:
-                if not os.path.exists (path):
-                    os.mkdir(path)
-                if not os.path.isdir (path):
-                    raise Exception
-            mounts=file('/proc/mounts').read()
-            if mounts.find(sliver_ssh)<0:
-                # xxx perform mount
-                subprocess.call("mount --bind -o ro %s %s"%(root_ssh,sliver_ssh),shell=True)
-                logger.log("expose_ssh_dir: %s mounted into slice %s"%(root_ssh,self.name))
-        except:
-            logger.log_exc("expose_ssh_dir with slice %s failed"%self.name)
-
     def start(self, delay=0):
         if self.rspec['enabled'] <= 0:
             logger.log('sliver_vs: not starting %s, is not enabled'%self.name)
index 6264571..d118fff 100644 (file)
@@ -14,7 +14,7 @@ import time
 import logger
 import api, api_calls
 import database
-import accounts
+import account
 import controller
 import sliver_lxc
 
@@ -210,8 +210,8 @@ def start():
     #for resname, default_amount in sliver_vs.DEFAULT_ALLOCATION.iteritems():
     #    DEFAULT_ALLOCATION[resname]=default_amount
 
-    accounts.register_class(sliver_lxc.Sliver_LXC)
-    accounts.register_class(controller.Controller)
+    account.register_class(sliver_vs.Sliver_VS)
+    account.register_class(controller.Controller)
     database.start()
     api_calls.deliver_ticket = deliver_ticket
     api.start()
index 0012908..c6dc4f7 100644 (file)
--- a/ticket.py
+++ b/ticket.py
@@ -1,6 +1,3 @@
-# $Id$
-# $URL$
-
 """An extremely simple interface to the signing/verifying capabilities
 of gnupg.
 
index 9aee6a4..36754fc 100644 (file)
--- a/tools.py
+++ b/tools.py
@@ -1,6 +1,3 @@
-# $Id$
-# $URL$
-
 """A few things that didn't seem to fit anywhere else."""
 
 import os, os.path