misplaced indentation - caused set_resources to bail out as deep as accounts:_run
[nodemanager.git] / sm.py
diff --git a/sm.py b/sm.py
index d3812fc..3147a09 100644 (file)
--- a/sm.py
+++ b/sm.py
@@ -7,7 +7,7 @@ also to make inter-sliver resource loans.  The sliver manager is also
 responsible for handling delegation accounts.
 """
 
-# $Id: sm.py,v 1.25 2007/07/20 19:35:29 faiyaza Exp $
+# $Id: sm.py,v 1.28 2007/07/27 18:02:36 dhozac Exp $
 
 try: from bwlimit import bwmin, bwmax
 except ImportError: bwmin, bwmax = 8, 1000*1000*1000
@@ -41,6 +41,8 @@ DEFAULT_ALLOCATION = {
     'disk_max': 5000000, # bytes
     # capabilities
     'capabilities': '',
+    # IP addresses
+    'ip_addresses': '0.0.0.0',
 
     # NOTE: this table is further populated with resource names and
     # default amounts via the start() function below.  This probably
@@ -57,6 +59,10 @@ def GetSlivers(data, fullupdate=True):
     in, use the GetSlivers() heartbeat as a cue to scan for expired
     slivers."""
 
+    logger.verbose("Entering sm:GetSlivers with fullupdate=%r"%fullupdate)
+    for key in data.keys():
+        logger.verbose('GetSlivers key : ' + key)
+
     node_id = None
     try:
         f = open('/etc/planetlab/node_id')
@@ -84,11 +90,13 @@ def GetSlivers(data, fullupdate=True):
 ### Emulab-specific hack ends here
 
 
+    logger.verbose ('dealing with initscripts')
     initscripts_by_id = {}
     for is_rec in data['initscripts']:
         initscripts_by_id[str(is_rec['initscript_id'])] = is_rec['script']
 
     for sliver in data['slivers']:
+        logger.verbose("sm:GetSlivers in slivers loop")
         rec = sliver.copy()
         rec.setdefault('timestamp', data['timestamp'])
 
@@ -119,13 +127,10 @@ def GetSlivers(data, fullupdate=True):
         rspec = {}
         rec['rspec'] = rspec
         for resname, default_amt in DEFAULT_ALLOCATION.iteritems():
-            try: amt = int(attr_dict[resname])
-            except KeyError: amt = default_amt
-            except ValueError:
-                if type(default_amt) is type('str'):
-                    amt = attr_dict[resname]
-                else:
-                    amt = default_amt
+            try:
+                t = type(default_amt)
+                amt = t.__new__(t, attr_dict[resname])
+            except (KeyError, ValueError): amt = default_amt
             rspec[resname] = amt
 
         database.db.deliver_record(rec)