spaces after comma
[nodemanager.git] / slivermanager.py
index 4e10b04..eb0a096 100644 (file)
@@ -7,7 +7,8 @@ also to make inter-sliver resource loans.  The sliver manager is also
 responsible for handling delegation accounts.
 """
 
-import string,re
+import string
+import re
 import time
 
 import logger
@@ -23,11 +24,15 @@ try:
     sliver_class_to_register = sliver_lxc.Sliver_LXC
     sliver_password_shell = sliver_lxc.Sliver_LXC.SHELL
 except:
-    import sliver_vs
-    implementation='vs'
-    sliver_default_type='sliver.VServer'
-    sliver_class_to_register = sliver_vs.Sliver_VS
-    sliver_password_shell = sliver_vs.Sliver_VS.SHELL
+    try:
+        import sliver_vs
+        implementation='vs'
+        sliver_default_type='sliver.VServer'
+        sliver_class_to_register = sliver_vs.Sliver_VS
+        sliver_password_shell = sliver_vs.Sliver_VS.SHELL
+    except:
+        logger.log("Could not import either sliver_lxc or sliver_vs - bailing out")
+        exit(1)
 
 # just being safe
 try : from plnode.bwlimit import bwmin, bwmax
@@ -42,6 +47,7 @@ DEFAULT_ALLOCATION = {
     'cpu_pct': 0, # percent CPU reserved
     'cpu_share': 1, # proportional share
     'cpu_cores': "0b", # reserved cpu cores <num_cores>[b]
+    'cpu_freezable': 0, # freeze processes if cpu_cores is 0
     # bandwidth parameters
     'net_min_rate': bwmin / 1000, # kbps
     'net_max_rate': bwmax / 1000, # kbps
@@ -144,7 +150,7 @@ def GetSlivers(data, config = None, plc=None, fullupdate=True):
     # Take initscripts (global) returned by API, build a hash scriptname->code
     iscripts_hash = {}
     if 'initscripts' not in data:
-        logger.log_missing_data("slivermanager.GetSlivers",'initscripts')
+        logger.log_missing_data("slivermanager.GetSlivers", 'initscripts')
         return
     for initscript_rec in data['initscripts']:
         logger.verbose("slivermanager: initscript: %s" % initscript_rec['name'])
@@ -178,7 +184,7 @@ def GetSlivers(data, config = None, plc=None, fullupdate=True):
 
         ### set initscripts; set empty rec['initscript'] if not
         # if tag 'initscript_code' is set, that's what we use
-        iscode = attributes.get('initscript_code','')
+        iscode = attributes.get('initscript_code', '')
         if iscode:
             rec['initscript']=iscode
         else: