Start the work on the query.

This commit is contained in:
Enol Fernandez 2015-03-27 17:23:05 +01:00
parent 63839d2b55
commit 7059d31396
1 changed files with 37 additions and 0 deletions

View File

@ -15,11 +15,48 @@
# under the License.
from ooi.api import base
from ooi.occi.core import entity
from ooi.occi.core import link
from ooi.occi.core import resource
from ooi.occi.infrastructure import compute
from ooi.occi.infrastructure import mixin as infra_mixin
from ooi.openstack import templates
class Controller(base.Controller):
def _resource_tpls(self, req):
tenant_id = req.environ["keystone.token_auth"].user.project_id
req = self._get_req(req, path="/%s/flavors" % tenant_id)
response = req.get_response(self.app)
flavors = response.json_body.get("flavors", [])
occi_resource_templates = []
if flavors:
for f in flavors:
r = templates.OpenStackResourceTemplate(f["name"],
f["vcpus"],
f["ram"],
f["disk"])
occi_resource_templates.append(r)
return occi_resource_templates
def index(self, req):
l = []
# OCCI Core Kinds:
l.append(entity.Entity.kind)
l.append(resource.Resource.kind)
l.append(link.Link.kind)
# OCCI infra Compute:
l.append(compute.ComputeResource.kind)
l.extend(compute.ComputeResource.actions)
# OCCI infra mixins
#l.append(infra_mixin.os_tpl)
#l.append(infra_mixin.resource_tpl)
# OpenStack flavors
l.extend(self._resource_tpls(req))
# OpenStack mixins (contextualization)
#l.append
return l