Fixed latency in flavor populating
authorJohn Giannelos <johngiannelos@gmail.com>
Mon, 30 Apr 2012 11:46:11 +0000 (14:46 +0300)
committerJohn Giannelos <johngiannelos@gmail.com>
Mon, 30 Apr 2012 11:46:11 +0000 (14:46 +0300)
snfOCCI/compute.py
snfOCCI/snf-occi-server.py

index 79a7e1e..279498f 100644 (file)
@@ -16,6 +16,8 @@ class MyBackend(KindBackend, ActionBackend):
     attributes. Support for links and mixins would need to added.
     '''
 
     attributes. Support for links and mixins would need to added.
     '''
 
+    # Update and Replace compute instances not supported by Cyclades
+
     def update(self, old, new, extras):
         raise AttributeError("This action is currently no applicable.")
 
     def update(self, old, new, extras):
         raise AttributeError("This action is currently no applicable.")
 
@@ -59,6 +61,7 @@ class ComputeBackend(MyBackend):
     def retrieve(self, entity, extras):
         
         # triggering cyclades to retrieve up to date information
     def retrieve(self, entity, extras):
         
         # triggering cyclades to retrieve up to date information
+
         conf = Config()
         conf.set('token',extras['token'])
         snf = ComputeClient(conf)
         conf = Config()
         conf.set('token',extras['token'])
         snf = ComputeClient(conf)
index 17ce9d1..4db0247 100755 (executable)
@@ -57,10 +57,11 @@ if __name__ == '__main__':
 
     flavors = snf.list_flavors()
     for flavor in flavors:
 
     flavors = snf.list_flavors()
     for flavor in flavors:
+        details = snf.get_flavor_details(flavor['id'])
         FLAVOR_ATTRIBUTES = {'occi.core.id': flavor['id'],
         FLAVOR_ATTRIBUTES = {'occi.core.id': flavor['id'],
-                             'occi.compute.cores': snf.get_flavor_details(flavor['id'])['cpu'],
-                             'occi.compute.memory': snf.get_flavor_details(flavor['id'])['ram'],
-                             'occi.storage.size': snf.get_flavor_details(flavor['id'])['disk'],
+                             'occi.compute.cores': details['cpu'],
+                             'occi.compute.memory': details['ram'],
+                             'occi.storage.size': details['disk'],
                              }
         FLAVOR = Mixin("http://schemas.ogf.org/occi/infrastructure#", str(flavor['name']), [RESOURCE_TEMPLATE], attributes = FLAVOR_ATTRIBUTES)
         APP.register_backend(FLAVOR, MixinBackend())
                              }
         FLAVOR = Mixin("http://schemas.ogf.org/occi/infrastructure#", str(flavor['name']), [RESOURCE_TEMPLATE], attributes = FLAVOR_ATTRIBUTES)
         APP.register_backend(FLAVOR, MixinBackend())