Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • tfs/controller
1 result
Show changes
Showing
with 89 additions and 21 deletions
# Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# 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 time
from flask_restful import Resource
from .Constants import START_TIME
class HealthProbe(Resource):
def get(self):
uptime = time.time() - START_TIME
return {'status': 'ready', 'uptime': uptime}, 200
#return {'status': 'not ready'}, 503
# Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# 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 nbi.service.NbiApplication import NbiApplication
from .Namespaces import HeartbeatServerNamespace
from .Resources import HealthProbe
def register_health_probes(nbi_app : NbiApplication):
nbi_app.add_rest_api_resource(HealthProbe, '/healthz', endpoint='sys.probe.healthz')
nbi_app.add_websocket_namespace(HeartbeatServerNamespace())
......@@ -19,7 +19,7 @@ from common.proto.context_pb2 import ConfigActionEnum, ConfigRule
from common.tools.context_queries.Device import get_device
from context.client.ContextClient import ContextClient
from device.client.DeviceClient import DeviceClient
from nbi.service.rest_server.nbi_plugins.tools.Authentication import HTTP_AUTH
from nbi.service._tools.Authentication import HTTP_AUTH
from .ietf_acl_parser import ietf_acl_from_config_rule_resource_value
LOGGER = logging.getLogger(__name__)
......
......@@ -22,7 +22,7 @@ from common.tools.context_queries.Device import get_device
from common.tools.grpc.Tools import grpc_message_to_json_string
from context.client.ContextClient import ContextClient
from device.client.DeviceClient import DeviceClient
from nbi.service.rest_server.nbi_plugins.tools.Authentication import HTTP_AUTH
from nbi.service._tools.Authentication import HTTP_AUTH
from .ietf_acl_parser import AclDirectionEnum, config_rule_from_ietf_acl
from .YangValidator import YangValidator
......
......@@ -12,27 +12,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from flask_restful import Resource
from nbi.service.rest_server.RestServer import RestServer
from nbi.service.NbiApplication import NbiApplication
from .Acl import Acl
from .Acls import Acls
URL_PREFIX = '/restconf/data'
def __add_resource(rest_server: RestServer, resource: Resource, *urls, **kwargs):
urls = [(URL_PREFIX + url) for url in urls]
rest_server.add_resource(resource, *urls, **kwargs)
def register_ietf_acl(rest_server: RestServer):
__add_resource(
rest_server,
def register_ietf_acl(nbi_app : NbiApplication):
nbi_app.add_rest_api_resource(
Acls,
'/device=<path:device_uuid>/ietf-access-control-list:acls',
URL_PREFIX + '/device=<path:device_uuid>/ietf-access-control-list:acls',
)
__add_resource(
rest_server,
nbi_app.add_rest_api_resource(
Acl,
'/device=<path:device_uuid>/ietf-access-control-list:acl=<path:acl_name>',
'/device=<path:device_uuid>/ietf-access-control-list:acl=<path:acl_name>/',
URL_PREFIX + '/device=<path:device_uuid>/ietf-access-control-list:acl=<path:acl_name>',
URL_PREFIX + '/device=<path:device_uuid>/ietf-access-control-list:acl=<path:acl_name>/',
)
......@@ -18,8 +18,8 @@ from flask.json import jsonify
from flask_restful import Resource
from common.tools.context_queries.Device import get_device
from context.client.ContextClient import ContextClient
from ..tools.Authentication import HTTP_AUTH
from ..tools.HttpStatusCodes import HTTP_OK, HTTP_SERVERERROR
from nbi.service._tools.Authentication import HTTP_AUTH
from nbi.service._tools.HttpStatusCodes import HTTP_OK, HTTP_SERVERERROR
from .YangHandler import YangHandler
LOGGER = logging.getLogger(__name__)
......
......@@ -18,8 +18,8 @@ from flask.json import jsonify
from flask_restful import Resource
from common.proto.context_pb2 import Empty
from context.client.ContextClient import ContextClient
from ..tools.Authentication import HTTP_AUTH
from ..tools.HttpStatusCodes import HTTP_OK, HTTP_SERVERERROR
from nbi.service._tools.Authentication import HTTP_AUTH
from nbi.service._tools.HttpStatusCodes import HTTP_OK, HTTP_SERVERERROR
from .YangHandler import YangHandler
LOGGER = logging.getLogger(__name__)
......
......@@ -12,13 +12,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from nbi.service.rest_server.nbi_plugins.ietf_hardware.Hardware import Hardware
from nbi.service.rest_server.nbi_plugins.ietf_hardware.HardwareMultipleDevices import HardwareMultipleDevices
from nbi.service.rest_server.RestServer import RestServer
from nbi.service.NbiApplication import NbiApplication
from .Hardware import Hardware
from .HardwareMultipleDevices import HardwareMultipleDevices
URL_PREFIX_DEVICE = "/restconf/data/device=<path:device_uuid>/ietf-network-hardware-inventory:network-hardware-inventory"
URL_PREFIX_HARDWARE = "/restconf/data/ietf-network-hardware-inventory:network-hardware-inventory"
URL_PREFIX = '/restconf/data'
def register_ietf_hardware(rest_server: RestServer):
rest_server.add_resource(Hardware, URL_PREFIX_DEVICE)
rest_server.add_resource(HardwareMultipleDevices, URL_PREFIX_HARDWARE)
def register_ietf_hardware(nbi_app : NbiApplication):
nbi_app.add_rest_api_resource(
Hardware,
URL_PREFIX + '/device=<path:device_uuid>/ietf-network-hardware-inventory:network-hardware-inventory'
)
nbi_app.add_rest_api_resource(
HardwareMultipleDevices,
URL_PREFIX + '/ietf-network-hardware-inventory:network-hardware-inventory'
)