From f76023dfa56d4a30f50eedc9ce3338befc7abced Mon Sep 17 00:00:00 2001 From: Jing Geng Date: Fri, 7 Jul 2023 17:07:22 +0000 Subject: [PATCH] basic api --- nova/api/openstack/compute/basic_api.py | 26 +++++++++++++++++++++++++ nova/api/openstack/compute/routes.py | 3 +++ 2 files changed, 29 insertions(+) create mode 100644 nova/api/openstack/compute/basic_api.py diff --git a/nova/api/openstack/compute/basic_api.py b/nova/api/openstack/compute/basic_api.py new file mode 100644 index 00000000000..8b9614152bb --- /dev/null +++ b/nova/api/openstack/compute/basic_api.py @@ -0,0 +1,26 @@ +"""Basic Controller""" + +#from nova.api.openstack.compute.schemas import xyz +#from nova.api.openstack import extensions +from nova.api.openstack import wsgi +from nova.api import validation + +class BasicController(wsgi.Controller): + + # Define support for GET on a collection + def index(self, req): + data = {'param': 'val'} + return data + + # Define support for POST on a collection +# @extensions.expected_errors((400, 409)) +# @validation.schema(xyz.create) + @wsgi.response(201) + def create(self, req, body): + write_body_here = ok + return response_body + + # Defining support for other RESTFul methods based on resource. + + # ... + diff --git a/nova/api/openstack/compute/routes.py b/nova/api/openstack/compute/routes.py index d0df3a5875c..ebaa0a0a859 100644 --- a/nova/api/openstack/compute/routes.py +++ b/nova/api/openstack/compute/routes.py @@ -25,6 +25,7 @@ from nova.api.openstack.compute import attach_interfaces from nova.api.openstack.compute import availability_zone from nova.api.openstack.compute import baremetal_nodes +from nova.api.openstack.compute import basic_api from nova.api.openstack.compute import cells from nova.api.openstack.compute import certificates from nova.api.openstack.compute import cloudpipe @@ -115,6 +116,8 @@ def _create_controller(main_controller, action_controller_list): availability_zone_controller = functools.partial( _create_controller, availability_zone.AvailabilityZoneController, []) +basic_controller = functools.partial( + _create_controller, basic_api.BasicController, []) baremetal_nodes_controller = functools.partial( _create_controller, baremetal_nodes.BareMetalNodeController, [])