fix allocation states
authorTony Mack <tmack@paris.CS.Princeton.EDU>
Thu, 25 Oct 2012 14:21:15 +0000 (10:21 -0400)
committerTony Mack <tmack@paris.CS.Princeton.EDU>
Thu, 25 Oct 2012 14:21:15 +0000 (10:21 -0400)
sfa/planetlab/plaggregate.py
sfa/planetlab/pldriver.py

index 936cb94..17abcb0 100644 (file)
@@ -238,7 +238,7 @@ class PlAggregate:
             nodes_dict[node['node_id']] = node
         return nodes_dict
 
-    def rspec_node_to_geni_sliver(self, rspec_node):
+    def rspec_node_to_geni_sliver(self, rspec_node, allocation_status=None):
         op_status = "geni_unknown"
         state = rspec_node['boot_state'].lower()
         if state == 'boot':
@@ -246,10 +246,13 @@ class PlAggregate:
         else:
             op_status =' geni_failed'
 
+        if not allocation_status:
+            allocation_status = 'provisioned'
+
         # required fields
         geni_sliver = {'geni_sliver_urn': rspec_node['sliver_id'],
                        'geni_expires': rspec_node['expires'],
-                       'geni_allocation_status': 'geni_provisioned',
+                       'geni_allocation_status': allocation_status,
                        'geni_operational_status': op_status,
                        'geni_error': None,
                        }
@@ -328,7 +331,7 @@ class PlAggregate:
             rspec.version.add_links(links)
         return rspec.toxml()
 
-    def describe(self, urns, version=None, options={}):
+    def describe(self, urns, version=None, options={}, allocation_status=None):
         version_manager = VersionManager()
         version = version_manager.get_version(version)
         rspec_version = version_manager._get_version(version.type, version.version, 'manifest')
@@ -361,7 +364,7 @@ class PlAggregate:
                 if sliver['slice_ids_whitelist'] and sliver['slice_id'] not in sliver['slice_ids_whitelist']:
                     continue
                 rspec_node = self.sliver_to_rspec_node(sliver, sites, interfaces, node_tags, pl_initscripts)
-                geni_sliver = self.rspec_node_to_geni_sliver(rspec_node)
+                geni_sliver = self.rspec_node_to_geni_sliver(rspec_node, allocation_status=allocation_status)
                 rspec_nodes.append(rspec_node) 
                 geni_slivers.append(geni_sliver)
             rspec.version.add_nodes(rspec_nodes)
index 75c230f..ab7846c 100644 (file)
@@ -700,10 +700,10 @@ class PlDriver (Driver):
         # only used by plc and ple.
         slices.handle_peer(site, slice, persons, peer)
         
-        return aggregate.describe([xrn.get_urn()], version=rspec.version)
+        return aggregate.describe([xrn.get_urn()], version=rspec.version, allocation_status='allocated')
 
     def provision(self, urns, options={}):
-        return self.describe(urns, None, options=options)
+        return self.describe(urns, None, options=options, allocation_status='provisioned')
 
     def delete(self, urns, options={}):
         names = []