Commit 711721d6 authored by John Giannelos's avatar John Giannelos
Browse files

Minor fixes/comments

parent ce25fdc1
......@@ -93,6 +93,8 @@ class ComputeBackend(MyBackend):
def delete(self, entity, extras):
#Deleting compute instance
conf = Config()
conf.set('token',extras['token'])
snf = ComputeClient(conf)
......@@ -103,6 +105,8 @@ class ComputeBackend(MyBackend):
def action(self, entity, action, extras):
#Triggering action to compute instances
conf = Config()
conf.set('token',extras['token'])
client = CycladesClient(conf)
......
......@@ -8,5 +8,3 @@ class snfRegistry(registry.NonePersistentRegistry):
resource.identifier = key
super(snfRegistry, self).add_resource(key, resource, extras)
......@@ -26,10 +26,29 @@ class MyAPP(Application):
def __call__(self, environ, response):
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())
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': 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())
#TODO up-to-date compute instances
# token will be represented in self.extras
return self._call_occi(environ, response, security = None, token = environ['HTTP_AUTH_TOKEN'])
......@@ -46,26 +65,6 @@ if __name__ == '__main__':
APP.register_backend(SUSPEND, COMPUTE_BACKEND)
APP.register_backend(RESOURCE_TEMPLATE, MixinBackend())
APP.register_backend(OS_TEMPLATE, MixinBackend())
snf = ComputeClient(Config())
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())
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': 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())
VALIDATOR_APP = validator(APP)
HTTPD = make_server('', SERVER_CONFIG['port'], VALIDATOR_APP)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment