Commit b7fca2d2 authored by John Giannelos's avatar John Giannelos
Browse files

Fixed compute instance naming

parent 711721d6
......@@ -50,7 +50,7 @@ class ComputeBackend(MyBackend):
snf = ComputeClient(conf)
vm_name = entity.attributes['occi.compute.hostname']
vm_name = entity.attributes['occi.core.title']
info = snf.create_server(vm_name, flavor_id, image_id)
entity.attributes[''] = str(info['id'])
entity.attributes['occi.compute.architecture'] = SERVER_CONFIG['compute_arch']
from kamaki.clients.compute import ComputeClient
from kamaki.clients.cyclades import CycladesClient
from kamaki.config import Config
from occi import registry
from occi.core_model import Mixin
from occi.backend import MixinBackend
from occi.extensions.infrastructure import RESOURCE_TEMPLATE, OS_TEMPLATE
class snfRegistry(registry.NonePersistentRegistry):
......@@ -24,18 +24,18 @@ class MyAPP(Application):
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 = {'': str(image['id'])}
IMAGE = Mixin("", 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'])
......@@ -45,9 +45,15 @@ class MyAPP(Application):
'': details['disk'],
FLAVOR = Mixin("", 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
# token will be represented in self.extras
return self._call_occi(environ, response, security = None, token = environ['HTTP_AUTH_TOKEN'])
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