From 81cd55de0440dcbc8df4d788565295d051ca91ad Mon Sep 17 00:00:00 2001 From: Bin Yang Date: Fri, 26 Nov 2021 15:47:46 +0800 Subject: [PATCH] Fix ocloudvirtualresource api typo Refactor o2dms Issue-ID: INF-239 Signed-off-by: Bin Yang Change-Id: Ibef4368a86bdbc662f4e80e566b7464b7d6d540b --- o2app/bootstrap.py | 4 +- o2app/entrypoints/flask_application.py | 4 +- o2common/service/messagebus.py | 10 ++ o2dms/views/__init__.py | 7 ++ o2dms/views/dms_route.py | 211 +-------------------------------- o2dms/views/nfdeployment_desc_route.py | 101 ++++++++++++++++ o2dms/views/nfdeployment_route.py | 101 ++++++++++++++++ o2dms/views/ocloud_vresource_route.py | 73 ++++++++++++ 8 files changed, 300 insertions(+), 211 deletions(-) create mode 100644 o2dms/views/nfdeployment_desc_route.py create mode 100644 o2dms/views/nfdeployment_route.py create mode 100644 o2dms/views/ocloud_vresource_route.py diff --git a/o2app/bootstrap.py b/o2app/bootstrap.py index 2e90768..6c5b276 100644 --- a/o2app/bootstrap.py +++ b/o2app/bootstrap.py @@ -72,11 +72,13 @@ def bootstrap( for command_type, handler in handlers.COMMAND_HANDLERS.items() } - return messagebus.MessageBus( + bus = messagebus.MessageBus( uow=uow, event_handlers=injected_event_handlers, command_handlers=injected_command_handlers, ) + messagebus.MessageBus.set_instance(bus) + return bus def inject_dependencies(handler, dependencies): diff --git a/o2app/entrypoints/flask_application.py b/o2app/entrypoints/flask_application.py index 65dab57..ab8c261 100644 --- a/o2app/entrypoints/flask_application.py +++ b/o2app/entrypoints/flask_application.py @@ -17,7 +17,7 @@ from flask_restx import Api from o2app import bootstrap from o2ims.views import ocloud_route as ims_route -from o2dms.views import dms_route +from o2dms.views import configure_namespace as dms_route_configure_namespace # apibase = config.get_o2ims_api_base() @@ -31,4 +31,4 @@ api = Api(app, version='1.0.0', bus = bootstrap.bootstrap() ims_route.configure_namespace(api, bus) -dms_route.configure_namespace(api, bus) +dms_route_configure_namespace(api) diff --git a/o2common/service/messagebus.py b/o2common/service/messagebus.py index 6c60c28..8c76ce6 100644 --- a/o2common/service/messagebus.py +++ b/o2common/service/messagebus.py @@ -27,6 +27,16 @@ Message = Union[commands.Command, events.Event] class MessageBus: + __instance: MessageBus = None + + @staticmethod + def set_instance(instance: MessageBus): + MessageBus.__instance = instance + + @staticmethod + def get_instance() -> MessageBus: + return MessageBus.__instance + def __init__( self, uow: unit_of_work.AbstractUnitOfWork, diff --git a/o2dms/views/__init__.py b/o2dms/views/__init__.py index ce75f50..7a888a6 100644 --- a/o2dms/views/__init__.py +++ b/o2dms/views/__init__.py @@ -13,6 +13,13 @@ # limitations under the License. from flask_restx import Namespace +from o2common.config import config + api_dms_lcm_v1 = Namespace( "O2DMS_LCM", description='DMS LCM related operations.') +apibase = config.get_o2dms_api_base() + + +def configure_namespace(app): + app.add_namespace(api_dms_lcm_v1, path=apibase) diff --git a/o2dms/views/dms_route.py b/o2dms/views/dms_route.py index 0fc6e69..4541258 100644 --- a/o2dms/views/dms_route.py +++ b/o2dms/views/dms_route.py @@ -15,13 +15,9 @@ # from flask import jsonify from flask_restx import Resource -from o2common.config import config -from o2dms.views.dms_dto import DmsDTO, DmsLcmNfDeploymentDescriptorDTO -from o2dms.views.dms_dto import DmsLcmNfDeploymentDTO -from o2dms.views.dms_dto import DmsLcmNfOCloudVResourceDTO +from o2dms.views.dms_dto import DmsDTO from o2dms.views import dms_lcm_view, api_dms_lcm_v1 - -apibase = config.get_o2dms_api_base() +from o2common.service.messagebus import MessageBus # ---------- DeploymentManagers ---------- # @@ -35,211 +31,10 @@ class DmsGetRouter(Resource): @api_dms_lcm_v1.doc('Get deployment manager') @api_dms_lcm_v1.marshal_with(model) def get(self, deploymentManagerID): + bus = MessageBus.get_instance() result = dms_lcm_view.deployment_manager_one( deploymentManagerID, bus.uow) if result is not None: return result api_dms_lcm_v1.abort(404, "Deployment manager {} doesn't exist".format( deploymentManagerID)) - - -# LCM services # -@api_dms_lcm_v1\ - .route("//O2dms_DeploymentLifecycle/" - "NfDeploymentDescriptor") -@api_dms_lcm_v1\ - .param('deploymentManagerID', 'ID of the deployment manager') -@api_dms_lcm_v1.response(404, 'DMS LCM not found') -class DmsLcmNfDeploymentDescListRouter(Resource): - - model = DmsLcmNfDeploymentDescriptorDTO.NfDeploymentDescriptor_get - - createdto = DmsLcmNfDeploymentDescriptorDTO.NfDeploymentDescriptor_create - post_resp = DmsLcmNfDeploymentDescriptorDTO.\ - NfDeploymentDescriptor_create_post_resp - - @api_dms_lcm_v1.doc('Get a list of NfDeploymentDescriptor') - @api_dms_lcm_v1.marshal_list_with(model) - def get(self, deploymentManagerID): - return dms_lcm_view.lcm_nfdeploymentdesc_list( - deploymentManagerID, bus.uow) - - @api_dms_lcm_v1.doc('Create a NfDeploymentDescriptor') - @api_dms_lcm_v1.expect(createdto) - @api_dms_lcm_v1.marshal_with(post_resp, code=201) - def post(self, deploymentManagerID): - data = api_dms_lcm_v1.payload - id = dms_lcm_view.lcm_nfdeploymentdesc_create( - deploymentManagerID, data, bus.uow) - return {"id": id}, 201 - - -@api_dms_lcm_v1\ - .route("//O2dms_DeploymentLifecycle/" - "NfDeploymentDescriptor/") -@api_dms_lcm_v1\ - .param('deploymentManagerID', 'ID of the deployment manager') -@api_dms_lcm_v1.param('nfDeploymentDescriptorId', - 'ID of the NfDeploymentDescriptor') -@api_dms_lcm_v1.response(404, 'DMS LCM not found') -class DmsLcmNfDeploymentDescGetRouter(Resource): - - model = DmsLcmNfDeploymentDescriptorDTO.NfDeploymentDescriptor_get - updatedto = DmsLcmNfDeploymentDescriptorDTO.\ - NfDeploymentDescriptor_update - - @api_dms_lcm_v1.doc('Get a NfDeploymentDescriptor') - @api_dms_lcm_v1.marshal_with(model) - def get(self, nfDeploymentDescriptorId, deploymentManagerID): - result = dms_lcm_view\ - .lcm_nfdeploymentdesc_one(nfDeploymentDescriptorId, bus.uow) - if result is not None: - return result - api_dms_lcm_v1.abort( - 404, "NfDeploymentDescriptor {} doesn't exist".format( - nfDeploymentDescriptorId)) - - @api_dms_lcm_v1.doc('Update a NfDeploymentDescriptor') - @api_dms_lcm_v1.expect(updatedto) - def put(self, nfDeploymentDescriptorId, deploymentManagerID): - data = api_dms_lcm_v1.payload - dms_lcm_view.lcm_nfdeploymentdesc_update( - nfDeploymentDescriptorId, data, bus.uow) - return {}, 201 - - @api_dms_lcm_v1.doc('Delete NfDeploymentDescriptor by ID') - @api_dms_lcm_v1.response(204, 'NfDeploymentDescriptor deleted') - def delete(self, nfDeploymentDescriptorId, deploymentManagerID): - with bus.uow: - bus.uow.nfdeployment_descs.delete(nfDeploymentDescriptorId) - bus.uow.commit() - return '', 204 - - -# LCM services # -@api_dms_lcm_v1\ - .route("//O2dms_DeploymentLifecycle/" - "NfDeployment") -@api_dms_lcm_v1\ - .param('deploymentManagerID', 'ID of the deployment manager') -@api_dms_lcm_v1.response(404, 'DMS LCM not found') -class DmsLcmNfDeploymentListRouter(Resource): - - model = DmsLcmNfDeploymentDTO.NfDeployment_get - - createdto = DmsLcmNfDeploymentDTO.NfDeployment_create - post_resp = DmsLcmNfDeploymentDTO.\ - NfDeployment_create_post_resp - - @api_dms_lcm_v1.doc('Get a list of NfDeployment') - @api_dms_lcm_v1.marshal_list_with(model) - def get(self, deploymentManagerID): - return dms_lcm_view.lcm_nfdeployment_list( - deploymentManagerID, bus.uow) - - @api_dms_lcm_v1.doc('Create a NfDeployment') - @api_dms_lcm_v1.expect(createdto) - @api_dms_lcm_v1.marshal_with(post_resp, code=201) - def post(self, deploymentManagerID): - data = api_dms_lcm_v1.payload - id = dms_lcm_view.lcm_nfdeployment_create( - deploymentManagerID, data, bus.uow) - return {"id": id}, 201 - - -@api_dms_lcm_v1\ - .route("//O2dms_DeploymentLifecycle/" - "NfDeployment/") -@api_dms_lcm_v1\ - .param('deploymentManagerID', 'ID of the deployment manager') -@api_dms_lcm_v1.param('nfDeploymentId', - 'ID of the NfDeployment') -@api_dms_lcm_v1.response(404, 'DMS LCM not found') -class DmsLcmNfDeploymentGetRouter(Resource): - - model = DmsLcmNfDeploymentDTO.NfDeployment_get - updatedto = DmsLcmNfDeploymentDTO.\ - NfDeployment_update - - @api_dms_lcm_v1.doc('Get a NfDeploymentDescriptor') - @api_dms_lcm_v1.marshal_with(model) - def get(self, nfDeploymentId, deploymentManagerID): - result = dms_lcm_view\ - .lcm_nfdeployment_one(nfDeploymentId, bus.uow) - if result is not None: - return result - api_dms_lcm_v1.abort( - 404, "NfDeploymentDescriptor {} doesn't exist".format( - nfDeploymentId)) - - @api_dms_lcm_v1.doc('Update a NfDeployment') - @api_dms_lcm_v1.expect(updatedto) - def put(self, nfDeploymentId, deploymentManagerID): - data = api_dms_lcm_v1.payload - dms_lcm_view.lcm_nfdeployment_update( - nfDeploymentId, data, bus.uow) - return {}, 201 - - @api_dms_lcm_v1.doc('Delete NfDeployment by ID') - @api_dms_lcm_v1.response(204, 'NfDeployment deleted') - def delete(self, nfDeploymentId, deploymentManagerID): - with bus.uow: - bus.uow.nfdeployments.delete(nfDeploymentId) - bus.uow.commit() - return '', 204 - - -# LCM services # -@api_dms_lcm_v1\ - .route("//O2dms_DeploymentLifecycle/" - "NfDeployment//NfOCloudVirtualResource") -@api_dms_lcm_v1\ - .param('deploymentManagerID', 'ID of the Deployment Manager') -@api_dms_lcm_v1.param('nfDeploymentId', - 'ID of the NfDeployment') -@api_dms_lcm_v1.response(404, 'DMS LCM not found') -class DmsLcmNfOCloudVResListRouter(Resource): - - model = DmsLcmNfOCloudVResourceDTO.NfOCloudVResource_get - - @api_dms_lcm_v1.doc('Get a list of NfOCloudVirtualResource') - @api_dms_lcm_v1.marshal_list_with(model) - def get(self, nfDeploymentId, deploymentManagerID): - return dms_lcm_view.lcm_nfocloudvresource_list( - nfDeploymentId, bus.uow) - - -@api_dms_lcm_v1\ - .route("//O2dms_DeploymentLifecycle/" - "NfDeployment/" - "NfOCloudVirtualResource/") -@api_dms_lcm_v1\ - .param('deploymentManagerID', 'ID of the deployment manager') -@api_dms_lcm_v1.param('nfDeploymentId', - 'ID of the NfDeployment') -@api_dms_lcm_v1.param('nfOCloudVirtualResourceId', - 'ID of the NfOCloudVirtualResource') -@api_dms_lcm_v1.response(404, 'DMS LCM not found') -class DmsLcmNfOCloudVResGetRouter(Resource): - - model = DmsLcmNfOCloudVResourceDTO.NfOCloudVResource_get - - @api_dms_lcm_v1.doc('Get a NfOCloudVirtualResource') - @api_dms_lcm_v1.marshal_with(model) - def get(self, nfOCloudVirtualResourceId, - nfDeploymentId, deploymentManagerID): - result = dms_lcm_view\ - .lcm_nfocloudvresource_one(nfOCloudVirtualResourceId, bus.uow) - if result is not None: - return result - api_dms_lcm_v1.abort( - 404, "NfOCloudVirtualResource {} doesn't exist".format( - nfOCloudVirtualResourceId)) - - -def configure_namespace(app, bus_new): - app.add_namespace(api_dms_lcm_v1, path=apibase) - - # Set global uow - global bus - bus = bus_new diff --git a/o2dms/views/nfdeployment_desc_route.py b/o2dms/views/nfdeployment_desc_route.py new file mode 100644 index 0000000..7bcf3c3 --- /dev/null +++ b/o2dms/views/nfdeployment_desc_route.py @@ -0,0 +1,101 @@ +# Copyright (C) 2021 Wind River Systems, Inc. +# +# 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. + +# from flask import jsonify +from flask_restx import Resource + +from o2common.config import config +from o2dms.views.dms_dto import DmsLcmNfDeploymentDescriptorDTO +from o2dms.views import dms_lcm_view, api_dms_lcm_v1 +from o2common.service.messagebus import MessageBus + +apibase = config.get_o2dms_api_base() + + +# LCM services # +@api_dms_lcm_v1\ + .route("//O2dms_DeploymentLifecycle/" + "NfDeploymentDescriptor") +@api_dms_lcm_v1\ + .param('deploymentManagerID', 'ID of the deployment manager') +@api_dms_lcm_v1.response(404, 'DMS LCM not found') +class DmsLcmNfDeploymentDescListRouter(Resource): + + model = DmsLcmNfDeploymentDescriptorDTO.NfDeploymentDescriptor_get + + createdto = DmsLcmNfDeploymentDescriptorDTO.NfDeploymentDescriptor_create + post_resp = DmsLcmNfDeploymentDescriptorDTO.\ + NfDeploymentDescriptor_create_post_resp + + @api_dms_lcm_v1.doc('Get a list of NfDeploymentDescriptor') + @api_dms_lcm_v1.marshal_list_with(model) + def get(self, deploymentManagerID): + bus = MessageBus.get_instance() + return dms_lcm_view.lcm_nfdeploymentdesc_list( + deploymentManagerID, bus.uow) + + @api_dms_lcm_v1.doc('Create a NfDeploymentDescriptor') + @api_dms_lcm_v1.expect(createdto) + @api_dms_lcm_v1.marshal_with(post_resp, code=201) + def post(self, deploymentManagerID): + bus = MessageBus.get_instance() + data = api_dms_lcm_v1.payload + id = dms_lcm_view.lcm_nfdeploymentdesc_create( + deploymentManagerID, data, bus.uow) + return {"id": id}, 201 + + +@api_dms_lcm_v1\ + .route("//O2dms_DeploymentLifecycle/" + "NfDeploymentDescriptor/") +@api_dms_lcm_v1\ + .param('deploymentManagerID', 'ID of the deployment manager') +@api_dms_lcm_v1.param('nfDeploymentDescriptorId', + 'ID of the NfDeploymentDescriptor') +@api_dms_lcm_v1.response(404, 'DMS LCM not found') +class DmsLcmNfDeploymentDescGetRouter(Resource): + + model = DmsLcmNfDeploymentDescriptorDTO.NfDeploymentDescriptor_get + updatedto = DmsLcmNfDeploymentDescriptorDTO.\ + NfDeploymentDescriptor_update + + @api_dms_lcm_v1.doc('Get a NfDeploymentDescriptor') + @api_dms_lcm_v1.marshal_with(model) + def get(self, nfDeploymentDescriptorId, deploymentManagerID): + bus = MessageBus.get_instance() + result = dms_lcm_view\ + .lcm_nfdeploymentdesc_one(nfDeploymentDescriptorId, bus.uow) + if result is not None: + return result + api_dms_lcm_v1.abort( + 404, "NfDeploymentDescriptor {} doesn't exist".format( + nfDeploymentDescriptorId)) + + @api_dms_lcm_v1.doc('Update a NfDeploymentDescriptor') + @api_dms_lcm_v1.expect(updatedto) + def put(self, nfDeploymentDescriptorId, deploymentManagerID): + bus = MessageBus.get_instance() + data = api_dms_lcm_v1.payload + dms_lcm_view.lcm_nfdeploymentdesc_update( + nfDeploymentDescriptorId, data, bus.uow) + return {}, 201 + + @api_dms_lcm_v1.doc('Delete NfDeploymentDescriptor by ID') + @api_dms_lcm_v1.response(204, 'NfDeploymentDescriptor deleted') + def delete(self, nfDeploymentDescriptorId, deploymentManagerID): + bus = MessageBus.get_instance() + with bus.uow: + bus.uow.nfdeployment_descs.delete(nfDeploymentDescriptorId) + bus.uow.commit() + return '', 204 diff --git a/o2dms/views/nfdeployment_route.py b/o2dms/views/nfdeployment_route.py new file mode 100644 index 0000000..962e6f4 --- /dev/null +++ b/o2dms/views/nfdeployment_route.py @@ -0,0 +1,101 @@ +# Copyright (C) 2021 Wind River Systems, Inc. +# +# 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. + +# from flask import jsonify +from flask_restx import Resource + +from o2common.config import config +from o2dms.views.dms_dto import DmsLcmNfDeploymentDTO +from o2dms.views import dms_lcm_view, api_dms_lcm_v1 +from o2common.service.messagebus import MessageBus + +apibase = config.get_o2dms_api_base() + + +# LCM services # +@api_dms_lcm_v1\ + .route("//O2dms_DeploymentLifecycle/" + "NfDeployment") +@api_dms_lcm_v1\ + .param('deploymentManagerID', 'ID of the deployment manager') +@api_dms_lcm_v1.response(404, 'DMS LCM not found') +class DmsLcmNfDeploymentListRouter(Resource): + + model = DmsLcmNfDeploymentDTO.NfDeployment_get + + createdto = DmsLcmNfDeploymentDTO.NfDeployment_create + post_resp = DmsLcmNfDeploymentDTO.\ + NfDeployment_create_post_resp + + @api_dms_lcm_v1.doc('Get a list of NfDeployment') + @api_dms_lcm_v1.marshal_list_with(model) + def get(self, deploymentManagerID): + bus = MessageBus.get_instance() + return dms_lcm_view.lcm_nfdeployment_list( + deploymentManagerID, bus.uow) + + @api_dms_lcm_v1.doc('Create a NfDeployment') + @api_dms_lcm_v1.expect(createdto) + @api_dms_lcm_v1.marshal_with(post_resp, code=201) + def post(self, deploymentManagerID): + bus = MessageBus.get_instance() + data = api_dms_lcm_v1.payload + id = dms_lcm_view.lcm_nfdeployment_create( + deploymentManagerID, data, bus.uow) + return {"id": id}, 201 + + +@api_dms_lcm_v1\ + .route("//O2dms_DeploymentLifecycle/" + "NfDeployment/") +@api_dms_lcm_v1\ + .param('deploymentManagerID', 'ID of the deployment manager') +@api_dms_lcm_v1.param('nfDeploymentId', + 'ID of the NfDeployment') +@api_dms_lcm_v1.response(404, 'DMS LCM not found') +class DmsLcmNfDeploymentGetRouter(Resource): + + model = DmsLcmNfDeploymentDTO.NfDeployment_get + updatedto = DmsLcmNfDeploymentDTO.\ + NfDeployment_update + + @api_dms_lcm_v1.doc('Get a NfDeploymentDescriptor') + @api_dms_lcm_v1.marshal_with(model) + def get(self, nfDeploymentId, deploymentManagerID): + bus = MessageBus.get_instance() + result = dms_lcm_view\ + .lcm_nfdeployment_one(nfDeploymentId, bus.uow) + if result is not None: + return result + api_dms_lcm_v1.abort( + 404, "NfDeploymentDescriptor {} doesn't exist".format( + nfDeploymentId)) + + @api_dms_lcm_v1.doc('Update a NfDeployment') + @api_dms_lcm_v1.expect(updatedto) + def put(self, nfDeploymentId, deploymentManagerID): + bus = MessageBus.get_instance() + data = api_dms_lcm_v1.payload + dms_lcm_view.lcm_nfdeployment_update( + nfDeploymentId, data, bus.uow) + return {}, 201 + + @api_dms_lcm_v1.doc('Delete NfDeployment by ID') + @api_dms_lcm_v1.response(204, 'NfDeployment deleted') + def delete(self, nfDeploymentId, deploymentManagerID): + bus = MessageBus.get_instance() + with bus.uow: + bus.uow.nfdeployments.delete(nfDeploymentId) + bus.uow.commit() + return '', 204 diff --git a/o2dms/views/ocloud_vresource_route.py b/o2dms/views/ocloud_vresource_route.py new file mode 100644 index 0000000..4f0adfd --- /dev/null +++ b/o2dms/views/ocloud_vresource_route.py @@ -0,0 +1,73 @@ +# Copyright (C) 2021 Wind River Systems, Inc. +# +# 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. + +# from flask import jsonify +from flask_restx import Resource + +from o2common.config import config +from o2dms.views.dms_dto import DmsLcmNfOCloudVResourceDTO +from o2dms.views import dms_lcm_view, api_dms_lcm_v1 +from o2common.service.messagebus import MessageBus + +apibase = config.get_o2dms_api_base() + + +# LCM services # +@api_dms_lcm_v1\ + .route("//O2dms_DeploymentLifecycle/" + "NfDeployment//NfOCloudVirtualResource") +@api_dms_lcm_v1\ + .param('deploymentManagerID', 'ID of the Deployment Manager') +@api_dms_lcm_v1.param('nfDeploymentId', + 'ID of the NfDeployment') +@api_dms_lcm_v1.response(404, 'DMS LCM not found') +class DmsLcmNfOCloudVResListRouter(Resource): + + model = DmsLcmNfOCloudVResourceDTO.NfOCloudVResource_get + + @api_dms_lcm_v1.doc('Get a list of NfOCloudVirtualResource') + @api_dms_lcm_v1.marshal_list_with(model) + def get(self, nfDeploymentId, deploymentManagerID): + bus = MessageBus.get_instance() + return dms_lcm_view.lcm_nfocloudvresource_list( + nfDeploymentId, bus.uow) + + +@api_dms_lcm_v1\ + .route("//O2dms_DeploymentLifecycle/" + "NfDeployment//" + "NfOCloudVirtualResource/") +@api_dms_lcm_v1\ + .param('deploymentManagerID', 'ID of the deployment manager') +@api_dms_lcm_v1.param('nfDeploymentId', + 'ID of the NfDeployment') +@api_dms_lcm_v1.param('nfOCloudVirtualResourceId', + 'ID of the NfOCloudVirtualResource') +@api_dms_lcm_v1.response(404, 'DMS LCM not found') +class DmsLcmNfOCloudVResGetRouter(Resource): + + model = DmsLcmNfOCloudVResourceDTO.NfOCloudVResource_get + + @api_dms_lcm_v1.doc('Get a NfOCloudVirtualResource') + @api_dms_lcm_v1.marshal_with(model) + def get(self, nfOCloudVirtualResourceId, + nfDeploymentId, deploymentManagerID): + bus = MessageBus.get_instance() + result = dms_lcm_view\ + .lcm_nfocloudvresource_one(nfOCloudVirtualResourceId, bus.uow) + if result is not None: + return result + api_dms_lcm_v1.abort( + 404, "NfOCloudVirtualResource {} doesn't exist".format( + nfOCloudVirtualResourceId)) -- 2.16.6