Merge "Info endpoint"
This commit is contained in:
commit
431ece5581
@ -284,6 +284,16 @@ directory.
|
||||
[notifier]
|
||||
notify = [ {"type": "webhook", "url": "http://example.com", "headers": {"X-Auth-Token": "XXXX"}}, {"type": "custom_publisher"} ]
|
||||
|
||||
#. Configure info endpoint. Info endpoint could be used for exposing some
|
||||
important for support data in json format. This endpoint should be enabled
|
||||
manually. Store filled info file into environment where Mistral will be
|
||||
running.
|
||||
|
||||
The default configuration is the following::
|
||||
[api]
|
||||
enable_info_endpoint = False
|
||||
info_json_file_path = info.json
|
||||
|
||||
#. Finally, try to run mistral engine and verify that it is running without
|
||||
any error::
|
||||
|
||||
|
39
mistral/api/controllers/info.py
Normal file
39
mistral/api/controllers/info.py
Normal file
@ -0,0 +1,39 @@
|
||||
# Copyright 2022 - NetCracker Technology Corp.
|
||||
#
|
||||
# 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 json
|
||||
from mistral import exceptions as exc
|
||||
from mistral.utils import rest_utils
|
||||
import os.path
|
||||
from oslo_config import cfg
|
||||
import pecan
|
||||
from pecan import rest
|
||||
|
||||
|
||||
class InfoController(rest.RestController):
|
||||
|
||||
@rest_utils.wrap_pecan_controller_exception
|
||||
@pecan.expose('json')
|
||||
def get(self):
|
||||
if not cfg.CONF.api.enable_info_endpoint:
|
||||
raise exc.InfoEndpointNotAvailableException(
|
||||
"Info endpoint disabled."
|
||||
)
|
||||
file_path = cfg.CONF.api.info_json_file_path
|
||||
if not os.path.exists(file_path):
|
||||
raise exc.InfoEndpointNotAvailableException(
|
||||
"Incorrect path to info json file."
|
||||
)
|
||||
with open(file_path) as f:
|
||||
return json.load(f)
|
@ -17,6 +17,7 @@ import pecan
|
||||
from wsme import types as wtypes
|
||||
import wsmeext.pecan as wsme_pecan
|
||||
|
||||
from mistral.api.controllers import info
|
||||
from mistral.api.controllers import resource
|
||||
from mistral.api.controllers.v2 import root as v2_root
|
||||
|
||||
@ -62,6 +63,7 @@ class APIVersions(resource.Resource):
|
||||
|
||||
class RootController(object):
|
||||
v2 = v2_root.Controller()
|
||||
info = info.InfoController()
|
||||
|
||||
@wsme_pecan.wsexpose(APIVersions)
|
||||
def index(self):
|
||||
|
@ -129,7 +129,19 @@ api_opts = [
|
||||
"turned off in the API request. 'disabled' disables validation "
|
||||
"for all API requests. 'mandatory' enables validation for all "
|
||||
"API requests.")
|
||||
)
|
||||
),
|
||||
cfg.BoolOpt(
|
||||
'enable_info_endpoint',
|
||||
default=False,
|
||||
help=_('Enable API for exposing info json about '
|
||||
'current Mistral build.')
|
||||
),
|
||||
cfg.StrOpt(
|
||||
'info_json_file_path',
|
||||
default='info.json',
|
||||
help=_("Specify the path to info json file which will be "
|
||||
"exposed via /info endpoint.")
|
||||
),
|
||||
]
|
||||
|
||||
js_impl_opt = cfg.StrOpt(
|
||||
|
@ -36,7 +36,13 @@ LOG = logging.getLogger(__name__)
|
||||
CONF = cfg.CONF
|
||||
|
||||
_CTX_THREAD_LOCAL_NAME = "MISTRAL_APP_CTX_THREAD_LOCAL"
|
||||
ALLOWED_WITHOUT_AUTH = ['/', '/v2/', '/workflowv2/', '/workflowv2/v2/']
|
||||
ALLOWED_WITHOUT_AUTH = [
|
||||
'/',
|
||||
'/info',
|
||||
'/v2/',
|
||||
'/workflowv2/',
|
||||
'/workflowv2/v2/'
|
||||
]
|
||||
|
||||
|
||||
class MistralContext(oslo_context.RequestContext):
|
||||
|
@ -190,6 +190,10 @@ class UnauthorizedException(MistralException):
|
||||
message = "Unauthorized"
|
||||
|
||||
|
||||
class InfoEndpointNotAvailableException(MistralException):
|
||||
http_code = 400
|
||||
|
||||
|
||||
class KombuException(Exception):
|
||||
def __init__(self, e):
|
||||
super(KombuException, self).__init__(e)
|
||||
|
Loading…
x
Reference in New Issue
Block a user