Revision b7fca2d2
b/snfOCCI/compute.py | ||
---|---|---|
50 | 50 |
conf.set('token',extras['token']) |
51 | 51 |
snf = ComputeClient(conf) |
52 | 52 |
|
53 |
vm_name = entity.attributes['occi.compute.hostname']
|
|
53 |
vm_name = entity.attributes['occi.core.title']
|
|
54 | 54 |
info = snf.create_server(vm_name, flavor_id, image_id) |
55 | 55 |
entity.attributes['occi.core.id'] = str(info['id']) |
56 | 56 |
entity.attributes['occi.compute.architecture'] = SERVER_CONFIG['compute_arch'] |
b/snfOCCI/registry.py | ||
---|---|---|
1 |
from kamaki.clients.compute import ComputeClient |
|
2 |
from kamaki.clients.cyclades import CycladesClient |
|
3 |
from kamaki.config import Config |
|
4 |
|
|
1 | 5 |
from occi import registry |
6 |
from occi.core_model import Mixin |
|
7 |
from occi.backend import MixinBackend |
|
8 |
from occi.extensions.infrastructure import RESOURCE_TEMPLATE, OS_TEMPLATE |
|
2 | 9 |
|
3 | 10 |
class snfRegistry(registry.NonePersistentRegistry): |
4 | 11 |
|
b/snfOCCI/snf-occi-server.py | ||
---|---|---|
24 | 24 |
An OCCI WSGI application. |
25 | 25 |
''' |
26 | 26 |
|
27 |
def __call__(self, environ, response):
|
|
27 |
def refresh_images(self):
|
|
28 | 28 |
|
29 | 29 |
snf = ComputeClient(Config()) |
30 |
|
|
31 |
#Up-to-date flavors and images |
|
32 |
|
|
33 | 30 |
images = snf.list_images() |
34 | 31 |
for image in images: |
35 | 32 |
IMAGE_ATTRIBUTES = {'occi.core.id': str(image['id'])} |
36 | 33 |
IMAGE = Mixin("http://schemas.ogf.org/occi/infrastructure#", str(image['name']), [OS_TEMPLATE], attributes = IMAGE_ATTRIBUTES) |
37 |
APP.register_backend(IMAGE, MixinBackend())
|
|
34 |
self.register_backend(IMAGE, MixinBackend())
|
|
38 | 35 |
|
36 |
def refresh_flavors(self): |
|
37 |
|
|
38 |
snf = ComputeClient(Config()) |
|
39 | 39 |
flavors = snf.list_flavors() |
40 | 40 |
for flavor in flavors: |
41 | 41 |
details = snf.get_flavor_details(flavor['id']) |
... | ... | |
45 | 45 |
'occi.storage.size': details['disk'], |
46 | 46 |
} |
47 | 47 |
FLAVOR = Mixin("http://schemas.ogf.org/occi/infrastructure#", str(flavor['name']), [RESOURCE_TEMPLATE], attributes = FLAVOR_ATTRIBUTES) |
48 |
APP.register_backend(FLAVOR, MixinBackend()) |
|
48 |
self.register_backend(FLAVOR, MixinBackend()) |
|
49 |
|
|
50 |
|
|
51 |
def __call__(self, environ, response): |
|
52 |
|
|
53 |
#Up-to-date flavors and images |
|
49 | 54 |
|
50 |
#TODO up-to-date compute instances |
|
55 |
self.refresh_images() |
|
56 |
self.refresh_flavors() |
|
51 | 57 |
|
52 | 58 |
# token will be represented in self.extras |
53 | 59 |
return self._call_occi(environ, response, security = None, token = environ['HTTP_AUTH_TOKEN']) |
Also available in: Unified diff