1 # Copyright (C) 2021 Wind River Systems, Inc.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # from flask import jsonify
16 # from os.path import exists
17 # from flask import send_file
18 from flask_restx import Resource
20 from o2dms.api.dms_dto import DmsDTO
21 from o2dms.api import dms_lcm_view
22 from o2dms.api.dms_api_ns import api_dms_lcm_v1
24 from o2common.service.messagebus import MessageBus
25 from o2common.helper import o2logging
26 logger = o2logging.get_logger(__name__)
29 def configure_api_route():
33 # ---------- DeploymentManagers ---------- #
34 @api_dms_lcm_v1.route("/<deploymentManagerID>")
35 @api_dms_lcm_v1.param('deploymentManagerID', 'ID of the deployment manager')
36 # @api_dms_lcm_v1.param('profile', 'DMS profile: value supports "sol018"',
37 # _in='query', default='sol018')
38 @api_dms_lcm_v1.response(404, 'Deployment manager not found')
39 class DmsGetRouter(Resource):
41 model = DmsDTO.dms_get
43 @api_dms_lcm_v1.doc('Get deployment manager')
44 @api_dms_lcm_v1.marshal_with(model)
45 def get(self, deploymentManagerID):
46 logger.debug("get o2dms info:{}".format(
49 bus = MessageBus.get_instance()
51 # parser = reqparse.RequestParser()
52 # parser.add_argument('profile', location='args')
53 # args = parser.parse_args()
55 # result = dms_lcm_view.deployment_manager_one(
56 # deploymentManagerID, bus.uow, args.profile)
57 result = dms_lcm_view.deployment_manager_one(
58 deploymentManagerID, bus.uow)
59 if result is not None:
61 api_dms_lcm_v1.abort(404, "Deployment manager {} doesn't exist".format(
65 # @api_dms_lcm_v1.route("/<deploymentManagerID>/download/<filename>")
66 # @api_dms_lcm_v1.param('deploymentManagerID',
67 # 'ID of the deployment manager')
68 # @api_dms_lcm_v1.param('filename',
70 # @api_dms_lcm_v1.response(404, 'profile not found')
71 # class DeploymentManagerGetFileRouter(Resource):
72 # def get(self, deploymentManagerID, filename):
73 # path = "/tmp/kubeconfig_" + filename
76 # return send_file(path, as_attachment=True)
77 # api_dms_lcm_v1.abort(
79 # "Deployment manager {}'s Kube config file doesn't exist".
80 # format(deploymentManagerID))