fix for potential ValueError
[sfa.git] / sfa / planetlab / plaggregate.py
index b5e8073..d869cc1 100644 (file)
@@ -193,7 +193,7 @@ class PlAggregate:
         rspec_node = NodeElement()
         # xxx how to retrieve site['login_base']
         site=sites[node['site_id']]
-        rspec_node['component_id'] = PlXrn(self.driver.hrn, hostname=node['hostname']).get_urn()
+        rspec_node['component_id'] = hostname_to_urn(self.driver.hrn, site['login_base'], node['hostname'])
         rspec_node['component_name'] = node['hostname']
         rspec_node['component_manager_id'] = Xrn(self.driver.hrn, 'authority+cm').get_urn()
         rspec_node['authority_id'] = hrn_to_urn(PlXrn.site_hrn(self.driver.hrn, site['login_base']), 'authority+sa')
@@ -203,7 +203,13 @@ class PlAggregate:
             rspec_node['available'] = 'true'
         else:
             rspec_node['available'] = 'false'
-        rspec_node['exclusive'] = 'false'
+
+        #distinguish between Shared and Reservable nodes
+        if node['node_type'] == 'reservable':
+            rspec_node['exclusive'] = 'true'
+        else:
+            rspec_node['exclusive'] = 'false'
+
         rspec_node['hardware_types'] = [HardwareType({'name': 'plab-pc'}),
                                         HardwareType({'name': 'pc'})]
         # only doing this because protogeni rspec needs
@@ -311,6 +317,9 @@ class PlAggregate:
                     op_status = 'geni_unknown'
             else:
                 allocation_status = 'geni_unallocated'    
+        else:
+            allocation_status = 'geni_unallocated'
+            op_status = 'geni_failed'
         # required fields
         geni_sliver = {'geni_sliver_urn': rspec_node['sliver_id'],
                        'geni_expires': rspec_node['expires'],
@@ -322,9 +331,6 @@ class PlAggregate:
 
     def get_leases(self, slice=None, options={}):
         
-        if slice_xrn and not slice:
-            return []
-
         now = int(time.time())
         filter={}
         filter.update({'clip':now})