An OCCI WSGI application.
'''
- def __call__(self, environ, response):
+ def refresh_images(self):
snf = ComputeClient(Config())
-
- #Up-to-date flavors and images
-
images = snf.list_images()
for image in images:
IMAGE_ATTRIBUTES = {'occi.core.id': str(image['id'])}
IMAGE = Mixin("http://schemas.ogf.org/occi/infrastructure#", str(image['name']), [OS_TEMPLATE], attributes = IMAGE_ATTRIBUTES)
- APP.register_backend(IMAGE, MixinBackend())
+ self.register_backend(IMAGE, MixinBackend())
+ def refresh_flavors(self):
+
+ snf = ComputeClient(Config())
flavors = snf.list_flavors()
for flavor in flavors:
details = snf.get_flavor_details(flavor['id'])
'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())
+ self.register_backend(FLAVOR, MixinBackend())
+
+
+ def __call__(self, environ, response):
+
+ #Up-to-date flavors and images
- #TODO up-to-date compute instances
+ self.refresh_images()
+ self.refresh_flavors()
# token will be represented in self.extras
return self._call_occi(environ, response, security = None, token = environ['HTTP_AUTH_TOKEN'])