- except: logger.log_exc()
-
- for d in data:
- if d['node_id'] != node_id: continue
- for sliver in d['slivers']:
- rec = sliver.copy()
- rec.setdefault('timestamp', d['timestamp'])
-
- # convert attributes field to a proper dict
- attr_dict = {}
- for attr in rec.pop('attributes'): attr_dict[attr['name']] = attr['value']
-
- # squash keys
- keys = rec.pop('keys')
- rec.setdefault('keys', '\n'.join([key_struct['key'] for key_struct in keys]))
-
+ except: logger.log_exc("sm: GetSlivers failed to read /etc/planetlab/node_id")
+
+ if data.has_key('node_id') and data['node_id'] != node_id: return
+
+ if data.has_key('networks'):
+ for network in data['networks']:
+ if network['is_primary'] and network['bwlimit'] is not None:
+ DEFAULT_ALLOCATION['net_max_rate'] = network['bwlimit'] / 1000
+
+ # Take intscripts (global) returned by API, make dict
+ if 'initscripts' not in data:
+ logger.log_missing_data("sm.GetSlivers",'initscripts')
+ return
+ initscripts = {}
+ for is_rec in data['initscripts']:
+ logger.verbose("sm: initscript: %s" % is_rec['name'])
+ initscripts[str(is_rec['name'])] = is_rec['script']
+
+ for sliver in data['slivers']:
+ logger.verbose("sm: %s: sm:GetSlivers in slivers loop"%sliver['name'])
+ rec = sliver.copy()
+ rec.setdefault('timestamp', data['timestamp'])
+
+ # convert attributes field to a proper dict
+ attr_dict = {}
+ for attr in rec.pop('attributes'): attr_dict[attr['tagname']] = attr['value']
+ rec.setdefault("attributes", attr_dict)
+
+ # squash keys
+ 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 same thing when you think about it. -FA
+ # Handle nm controller here
+ if rec['instantiation'].lower() == 'nm-controller':
+ rec.setdefault('type', attr_dict.get('type', 'controller.Controller'))
+ else: