various cosmetic changes
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Tue, 11 Dec 2007 12:02:46 +0000 (12:02 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Tue, 11 Dec 2007 12:02:46 +0000 (12:02 +0000)
NOTE.
I'm leaving vsliver_vs.py untouched
However, in set_resources, most of the calls to the lower level (vserver/vserverimpl)
methods are called unprotected by a try/except
If any of this fails, then the exception gets caught in accounts:_run only
and this might prevent correct operations
to make things worse, in such a case the error messages printed by vserverimpl
might get lost in daemon mode
So a cleanup in this area might be most useful

accounts.py
logger.py
nm.init
tools.py

index 3074e41..3711a0d 100644 (file)
@@ -81,7 +81,7 @@ class Account:
 
     def configure(self, rec):
         """Write <rec['keys']> to my authorized_keys file."""
-        logger.verbose('in accounts:configure')
+        logger.verbose('in accounts:configure for %s'%self.name)
         new_keys = rec['keys']
         if new_keys != self.keys:
             self.keys = new_keys
index bfc416b..0b083ca 100644 (file)
--- a/logger.py
+++ b/logger.py
@@ -21,6 +21,7 @@ LOG_VERBOSE=2
 LOG_LEVEL=1
 
 def set_level(level):
+    global LOG_LEVEL
     assert level in [LOG_NONE,LOG_NODE,LOG_VERBOSE]
     LOG_LEVEL=level
 
@@ -56,7 +57,7 @@ def log_slivers (data):
     import pprint, time
     try:
         f=open(LOG_SLIVERS,'w')
-        now=time.strftime("GetSlivers stored at %H:%M:%S", time.localtime())
+        now=time.strftime("GetSlivers stored on %Y.%m.%d at %H:%M:%S", time.localtime())
         f.write(now+'\n')
         pp=pprint.PrettyPrinter(stream=f,indent=2)
         pp.pprint(data)
diff --git a/nm.init b/nm.init
index 7fb3154..4ae386d 100755 (executable)
--- a/nm.init
+++ b/nm.init
@@ -15,7 +15,8 @@ fi
 
 nm=${NM-"python /usr/share/NodeManager/nm.py"}
 prog="Node Manager"
-restartoptions=
+options=${OPTIONS-"-d -s"}
+restartoptions=${RESTARTOPTIONS-"-d"}
 pidfile=${PIDFILE-/var/run/nm.pid}
 lockfile=${LOCKFILE-/var/lock/subsys/nm}
 RETVAL=0
@@ -32,7 +33,7 @@ do_start()
 
 start()
 {
-    do_start ${OPTIONS-"-d -s"}
+    do_start $options
 }
 
 stop()
@@ -51,7 +52,7 @@ stop()
 restart()
 {
     stop
-    do_start ${OPTIONS-"-d"}
+    do_start $restartoptions
 }
 
 
index f4496e1..49441bd 100644 (file)
--- a/tools.py
+++ b/tools.py
@@ -36,7 +36,8 @@ def daemon():
     os.umask(0)
     devnull = os.open(os.devnull, os.O_RDWR)
     os.dup2(devnull, 0)
-    crashlog = os.open('/root/nm.stderr', os.O_RDWR | os.O_APPEND | os.O_CREAT, 0644)
+    # xxx fixme - this is just to make sure that nothing gets stupidly lost - should use devnull
+    crashlog = os.open('/var/log/nm.daemon', os.O_RDWR | os.O_APPEND | os.O_CREAT, 0644)
     os.dup2(crashlog, 1)
     os.dup2(crashlog, 2)