fix SliverStatus is esses openstack driver
authorTony Mack <tmack@paris.CS.Princeton.EDU>
Tue, 14 Aug 2012 02:03:45 +0000 (22:03 -0400)
committerTony Mack <tmack@paris.CS.Princeton.EDU>
Tue, 14 Aug 2012 02:03:45 +0000 (22:03 -0400)
sfa/openstack/nova_driver.py
sfa/util/xrn.py

index e4ef961..7fb5393 100644 (file)
@@ -388,8 +388,7 @@ class NovaDriver(Driver):
     def sliver_status (self, slice_urn, slice_hrn):
         # find out where this slice is currently running
         project_name = hrn_to_os_slicename(slice_hrn)
-        project = self.shell.auth_manager.get_project(project_name)
-        instances = self.shell.db.instance_get_all_by_project(project_name)
+        instances = self.shell.nova_manager.servers.findall(name=project_name)
         if len(instances) == 0:
             raise SliverDoesNotExist("You have not allocated any slivers here") 
         
@@ -409,15 +408,14 @@ class NovaDriver(Driver):
             # instances are accessed by ip, not hostname. We need to report the ip
             # somewhere so users know where to ssh to.     
             res['geni_expires'] = None
-            res['plos_hostname'] = instance.hostname
-            res['plos_created_at'] = datetime_to_string(utcparse(instance.created_at))    
-            res['plos_boot_state'] = instance.vm_state
-            res['plos_sliver_type'] = instance.instance_type.name 
-            sliver_id =  Xrn(slice_urn).get_sliver_id(instance.project_id, \
-                                                      instance.hostname, instance.id)
+            #res['plos_hostname'] = instance.hostname
+            res['plos_created_at'] = datetime_to_string(utcparse(instance.created))    
+            res['plos_boot_state'] = instance.status
+            res['plos_sliver_type'] = self.shell.nova_manager.flavors.find(id=instance.flavor['id']).name 
+            sliver_id =  Xrn(slice_urn).get_sliver_id(instance.id)
             res['geni_urn'] = sliver_id
 
-            if instance.vm_state == 'running':
+            if instance.status.lower() == 'active':
                 res['boot_state'] = 'ready'
                 res['geni_status'] = 'ready'
             else:
index 8264f0a..4a47b58 100644 (file)
@@ -168,7 +168,7 @@ class Xrn:
         self._normalize()\r
         return ':'.join( [Xrn.unescape(x) for x in self.authority] )\r
 \r
-    def get_sliver_id(self, slice_id, node_id, index=0, authority=None):\r
+    def get_sliver_id(self, slice_id, node_id=None, index=0, authority=None):\r
         self._normalize()\r
         urn = self.get_urn()\r
         if authority:\r
@@ -178,7 +178,8 @@ class Xrn:
             else:\r
                 hrn = ".".join([authority_hrn, self.get_leaf()])\r
             urn = Xrn(hrn, self.get_type()).get_urn()\r
-        return ":".join(map(str, [urn, slice_id, node_id, index]))\r
+        parts = [part for part in [urn, slice_id, node_id, index] if part is not None]\r
+        return ":".join(map(str, [parts]))\r
 \r
     def urn_to_hrn(self):\r
         """\r