Commit 17e03a44 authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Implement get_images functionality

parent 1dd10f79
...@@ -30,7 +30,8 @@ ...@@ -30,7 +30,8 @@
from soi.log import reveale_me from soi.log import reveale_me
import json import json
from kamaki.clients.astakos import AstakosClient from kamaki.clients.astakos import AstakosClient
from kamaki.clients.cyclades import CycladesComputeClient from kamaki.clients.cyclades import (
CycladesComputeClient, CycladesNetworkClient)
from kamaki.clients.utils import https from kamaki.clients.utils import https
from soi.config import AUTH_URL, CA_CERTS from soi.config import AUTH_URL, CA_CERTS
...@@ -39,9 +40,11 @@ ADMIN_TOKEN = '' ...@@ -39,9 +40,11 @@ ADMIN_TOKEN = ''
https.patch_with_certs(CA_CERTS) https.patch_with_certs(CA_CERTS)
auth = AstakosClient(AUTH_URL, ADMIN_TOKEN) auth = AstakosClient(AUTH_URL, ADMIN_TOKEN)
endpoints, client_classes = {}, {} endpoints = {'identity': AUTH_URL}
for cls in (AstakosClient, CycladesComputeClient): client_classes = {'identity': AstakosClient}
service_type = CycladesComputeClient.service_type
for cls in (CycladesComputeClient, CycladesNetworkClient):
service_type = cls.service_type
endpoints[service_type] = auth.get_endpoint_url(service_type) endpoints[service_type] = auth.get_endpoint_url(service_type)
client_classes[service_type] = cls client_classes[service_type] = cls
...@@ -59,6 +62,8 @@ def call_kamaki(environ, start_response, *args, **kwargs): ...@@ -59,6 +62,8 @@ def call_kamaki(environ, start_response, *args, **kwargs):
method_name = environ.pop('method_name') method_name = environ.pop('method_name')
kwargs = environ.pop('kwargs', {}) kwargs = environ.pop('kwargs', {})
print '\t', service_type, method_name, kwargs
endpoint = endpoints[service_type] endpoint = endpoints[service_type]
token = environ['HTTP_X_AUTH_TOKEN'] token = environ['HTTP_X_AUTH_TOKEN']
cls = client_classes[service_type] cls = client_classes[service_type]
......
...@@ -36,16 +36,18 @@ def snf_get_flavors(cls, req): ...@@ -36,16 +36,18 @@ def snf_get_flavors(cls, req):
return cls.get_from_response(response, 'flavors', []) return cls.get_from_response(response, 'flavors', [])
OpenStackHelper.index = snf_index def snf_get_images(cls, req):
OpenStackHelper.get_flavors = snf_get_flavors """Synnefo: list images"""
req.environ['service_type'] = 'compute'
req.environ['method_name'] = 'images_get'
# Test ground req.environ['kwargs'] = {'detail': True}
response = req.get_response(cls.app)
from soi.log import reveale_cme return cls.get_from_response(response, 'images', [])
# end test ground OpenStackHelper.index = snf_index
OpenStackHelper.get_flavors = snf_get_flavors
OpenStackHelper.get_images = snf_get_images
class SNFOCCIMiddleware(OCCIMiddleware): class SNFOCCIMiddleware(OCCIMiddleware):
......
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