the hardware_types in a node rspec is now built by
[sfa.git] / sfa / planetlab / plaggregate.py
index a6b76da..dfae5d5 100644 (file)
@@ -264,8 +264,21 @@ class PlAggregate:
         else:
             rspec_node['exclusive'] = 'false'
 
-        rspec_node['hardware_types'] = [HardwareType({'name': 'plab-pc'}),
-                                        HardwareType({'name': 'pc'})]
+        # expose hardware_types from the hardware_type tag if
+        # set on node
+        tags = self.driver.shell.GetNodeTags({
+            'node_id': node['node_id'],
+            'tagname': 'hardware_type',
+        })
+        if tags:
+            rspec_node['hardware_types'] = [
+                HardwareType({'name': tags[0]['value']}),
+            ]
+        else:
+            rspec_node['hardware_types'] = [
+                HardwareType({'name': 'plab-pc'}),
+                HardwareType({'name': 'pc'})
+        ]
         # only doing this because protogeni rspec needs
         # to advertise available initscripts
         rspec_node['pl_initscripts'] = pl_initscripts.values()
@@ -278,11 +291,11 @@ class PlAggregate:
             }
             for extra in ('country', 'city'):
                 try:
-                    tts = self.driver.shell.GetSiteTags({
+                    tags = self.driver.shell.GetSiteTags({
                         'site_id' : site['site_id'],
                         'tagname' : extra,
                     })
-                    location_dict[extra] = tts[0]['value']
+                    location_dict[extra] = tags[0]['value']
                 except:
                     logger.log_exc('extra = {}'.format(extra))
                     location_dict[extra] = 'unknown'
@@ -492,10 +505,11 @@ class PlAggregate:
             node_tags = self.get_node_tags({'node_tag_id': tag_ids})
             pl_initscripts = self.get_pl_initscripts()
             # convert nodes to rspec nodes
+            grain = self.driver.shell.GetLeaseGranularity()
             rspec_nodes = []
             for node in nodes:
                 rspec_node = self.node_to_rspec_node(
-                    node, sites, interfaces, node_tags, pl_initscripts)
+                    node, sites, interfaces, node_tags, pl_initscripts, grain)
                 rspec_nodes.append(rspec_node)
             rspec.version.add_nodes(rspec_nodes)