From: John Giannelos Date: Mon, 30 Apr 2012 11:46:11 +0000 (+0300) Subject: Fixed latency in flavor populating X-Git-Url: https://code.grnet.gr/git/snf-occi/commitdiff_plain/3c3c94f2afa67e94fa7b0b6e24ff927c4957a3d3?hp=d7dfc401c4b23e193f996e3e03b0a941d64ce6c2 Fixed latency in flavor populating --- diff --git a/snfOCCI/compute.py b/snfOCCI/compute.py index 79a7e1e..279498f 100644 --- a/snfOCCI/compute.py +++ b/snfOCCI/compute.py @@ -16,6 +16,8 @@ class MyBackend(KindBackend, ActionBackend): 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.") @@ -59,6 +61,7 @@ class ComputeBackend(MyBackend): def retrieve(self, entity, extras): # triggering cyclades to retrieve up to date information + conf = Config() conf.set('token',extras['token']) snf = ComputeClient(conf) diff --git a/snfOCCI/snf-occi-server.py b/snfOCCI/snf-occi-server.py index 17ce9d1..4db0247 100755 --- a/snfOCCI/snf-occi-server.py +++ b/snfOCCI/snf-occi-server.py @@ -57,10 +57,11 @@ if __name__ == '__main__': flavors = snf.list_flavors() for flavor in flavors: + details = snf.get_flavor_details(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())