Add vnflcm support base framework

Added vnflcm controller and router Rest API code.

Change-Id: I237f263df7eb41c0ca768869a8e5ce25637f13ca
Blueprint: support-etsi-nfv-specs
This commit is contained in:
Ajay Parja 2019-12-05 07:47:47 +00:00 committed by tpatil
parent c74cad521c
commit dcbeac526b
5 changed files with 140 additions and 0 deletions

View File

@ -3,6 +3,7 @@ use = egg:Paste#urlmap
/: tackerversions
/v1.0: tackerapi_v1_0
/vnfpkgm/v1: vnfpkgmapi_v1
/vnflcm/v1: vnflcm_v1
[composite:tackerapi_v1_0]
use = call:tacker.auth:pipeline_factory
@ -14,6 +15,11 @@ use = call:tacker.auth:pipeline_factory
noauth = request_id catch_errors extensions vnfpkgmapp_v1
keystone = request_id catch_errors authtoken keystonecontext extensions vnfpkgmapp_v1
[composite:vnflcm_v1]
use = call:tacker.auth:pipeline_factory
noauth = request_id catch_errors vnflcmaapp_v1
keystone = request_id catch_errors authtoken keystonecontext vnflcmaapp_v1
[filter:request_id]
paste.filter_factory = oslo_middleware:RequestId.factory
@ -40,3 +46,6 @@ paste.app_factory = tacker.api.v1.router:APIRouter.factory
[app:vnfpkgmapp_v1]
paste.app_factory = tacker.api.vnfpkgm.v1.router:VnfpkgmAPIRouter.factory
[app:vnflcmaapp_v1]
paste.app_factory = tacker.api.vnflcm.v1.router:VnflcmAPIRouter.factory

View File

View File

View File

@ -0,0 +1,46 @@
# Copyright (C) 2020 NTT DATA
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import webob
from tacker import wsgi
class VnfLcmController(wsgi.Controller):
def create(self, request, body):
raise webob.exc.HTTPNotImplemented()
def show(self, request, id):
raise webob.exc.HTTPNotImplemented()
def index(self, request):
raise webob.exc.HTTPNotImplemented()
def delete(self, request, id):
raise webob.exc.HTTPNotImplemented()
def instantiate(self, request, id, body):
raise webob.exc.HTTPNotImplemented()
def terminate(self, request, id, body):
raise webob.exc.HTTPNotImplemented()
def heal(self, request, id, body):
raise webob.exc.HTTPNotImplemented()
def create_resource():
return wsgi.Resource(VnfLcmController())

View File

@ -0,0 +1,85 @@
# Copyright (C) 2020 NTT DATA
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import routes
from tacker.api.vnflcm.v1 import controller as vnf_lcm_controller
from tacker import wsgi
class VnflcmAPIRouter(wsgi.Router):
"""Routes requests on the API to the appropriate controller and method."""
def __init__(self):
mapper = routes.Mapper()
super(VnflcmAPIRouter, self).__init__(mapper)
def _setup_route(self, mapper, url, methods, controller,
default_resource):
all_methods = ['HEAD', 'GET', 'POST', 'PUT', 'PATCH', 'DELETE']
missing_methods = [m for m in all_methods if m not in methods.keys()]
allowed_methods_str = ",".join(methods.keys())
for method, action in methods.items():
mapper.connect(url,
controller=controller,
action=action,
conditions={'method': [method]})
if missing_methods:
mapper.connect(url,
controller=default_resource,
action='reject',
allowed_methods=allowed_methods_str,
conditions={'method': missing_methods})
def _setup_routes(self, mapper):
default_resource = wsgi.Resource(wsgi.DefaultMethodController(),
wsgi.RequestDeserializer())
controller = vnf_lcm_controller.create_resource()
# Allowed methods on /vnflcm/v1/vnf_instances resource
methods = {"GET": "index", "POST": "create"}
self._setup_route(mapper, "/vnf_instances",
methods, controller, default_resource)
# Allowed methods on
# /vnflcm/v1/vnf_instances/{vnfInstanceId} resource
methods = {"DELETE": "delete", "GET": "show"}
self._setup_route(mapper, "/vnf_instances/{id}",
methods, controller, default_resource)
# Allowed methods on
# /vnflcm/v1/vnf_instances/{vnfInstanceId}/instantiate resource
methods = {"POST": "instantiate"}
self._setup_route(mapper,
"/vnf_instances/{id}/instantiate",
methods, controller, default_resource)
# Allowed methods on
# /vnflcm/v1/vnf_instances/{vnfInstanceId}/terminate resource
methods = {"POST": "terminate"}
self._setup_route(mapper,
"/vnf_instances/{id}/terminate",
methods, controller, default_resource)
# Allowed methods on
# /vnflcm/v1/vnf_instances/{vnfInstanceId}/heal resource
methods = {"POST": "heal"}
self._setup_route(mapper,
"/vnf_instances/{id}/heal",
methods, controller, default_resource)