Commit 2412fb59 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Tests - Tools - SIMAP DataStore

- Migrated specific features on SIMAP Telemetry from common RESTCONF server to specific SIMAP DataStore
parent 9945487a
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -20,9 +20,3 @@ RESTCONF_PREFIX = os.environ.get('RESTCONF_PREFIX', '/restconf' )
YANG_SEARCH_PATH = os.environ.get('YANG_SEARCH_PATH', './yang'        )
STARTUP_FILE     = os.environ.get('STARTUP_FILE',     './startup.json')
SECRET_KEY       = os.environ.get('SECRET_KEY',       secrets.token_hex(64))

# InfluxDB Configuration
INFLUXDB_HOST     = os.environ.get('INFLUXDB_HOST',     'localhost'      )
INFLUXDB_PORT     = int(os.environ.get('INFLUXDB_PORT', '8181')          )
INFLUXDB_DATABASE = os.environ.get('INFLUXDB_DATABASE', 'simap_telemetry')
INFLUXDB_TOKEN    = os.environ.get('INFLUXDB_TOKEN',    'apiv3_xSq6xD1wBvZ21Pc3uPnqqmgLeSn-kZbz1y4S4u8GtSbJebEly8wl9WUjGJ0Ja_bQuwKB_lpDcHrNJUBCDJMSCw')
+1 −27
Original line number Diff line number Diff line
@@ -13,11 +13,8 @@
# limitations under the License.


from .callbacks import CallbackOnLinkTelemetry, CallbackOnNodeTelemetry
from .Config import INFLUXDB_HOST, INFLUXDB_PORT, INFLUXDB_TOKEN, INFLUXDB_DATABASE
from .influxdb_client import SimapInfluxDBClient
from .RestConfServerApplication import RestConfServerApplication
import logging
from .RestConfServerApplication import RestConfServerApplication


logging.basicConfig(
@@ -32,29 +29,6 @@ rcs_app.register_host_meta()
rcs_app.register_restconf()
LOGGER.info('All connectors registered')

# Initialize InfluxDB client and register telemetry callbacks
try:
    LOGGER.info('Initializing InfluxDB client (host=%s, port=%d, db=%s)...', INFLUXDB_HOST, INFLUXDB_PORT, INFLUXDB_DATABASE)
    influx_client = SimapInfluxDBClient(
        host     = INFLUXDB_HOST,
        port     = INFLUXDB_PORT,
        token    = INFLUXDB_TOKEN,
        database = INFLUXDB_DATABASE
    )
except Exception as e:
    LOGGER.error('Failed to initialize InfluxDB client: %s', e)
    influx_client = None

if influx_client is not None and influx_client.is_connected():
    try:
        rcs_app.callback_dispatcher.register(CallbackOnLinkTelemetry(influx_client))
        rcs_app.callback_dispatcher.register(CallbackOnNodeTelemetry(influx_client))
        LOGGER.info('Telemetry callbacks registered')
    except Exception as e:
        LOGGER.error('Failed to register telemetry callbacks: %s', e)
else:
    LOGGER.warning('InfluxDB client not connected, telemetry callbacks disabled.')

rcs_app.dump_configuration()
app = rcs_app.get_flask_app()

+8 −4
Original line number Diff line number Diff line
@@ -43,15 +43,19 @@ RUN python3 -m pip install --upgrade 'setuptools==79.0.0' 'wheel==0.45.1'
RUN python3 -m pip install --upgrade 'pip-tools==7.3.0'

# Create component sub-folders, get specific Python packages
RUN mkdir -p /var/teraflow/simap_datastore/
WORKDIR /var/teraflow/simap_datastore/
RUN mkdir -p /var/teraflow/
WORKDIR /var/teraflow/
COPY src/common/tools/rest_conf/server/requirements.in ./requirements.in
RUN pip-compile --quiet --output-file=requirements.txt requirements.in
RUN python3 -m pip install -r requirements.txt

# Add component files into working directory
COPY src/common/tools/rest_conf/server/restconf_server/ ./simap_datastore/
COPY src/tests/tools/simap_datastore/yang/*.yang ./yang/
RUN mkdir -p /var/teraflow/common/tools/
WORKDIR /var/teraflow/
COPY src/common/tools/rest_api/ ./common/tools/rest_api/
COPY src/common/tools/rest_conf/ ./common/tools/rest_conf/
COPY src/tests/tools/simap_datastore/simap_datastore/*.py ./simap_datastore/
COPY src/tests/tools/simap_datastore/yang/. ./yang/
COPY src/tests/tools/simap_datastore/startup.json ./startup.json

# Configure RESTCONF Datastore
+15 −0
Original line number Diff line number Diff line
# Copyright 2022-2025 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.

influxdb3-python==0.16.0
+28 −0
Original line number Diff line number Diff line
# Copyright 2022-2025 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 os, secrets


RESTCONF_PREFIX  = os.environ.get('RESTCONF_PREFIX',  '/restconf'     )
YANG_SEARCH_PATH = os.environ.get('YANG_SEARCH_PATH', './yang'        )
STARTUP_FILE     = os.environ.get('STARTUP_FILE',     './startup.json')
SECRET_KEY       = os.environ.get('SECRET_KEY',       secrets.token_hex(64))

# InfluxDB Configuration
INFLUXDB_HOST     = os.environ.get('INFLUXDB_HOST',     'localhost'      )
INFLUXDB_PORT     = int(os.environ.get('INFLUXDB_PORT', '8181')          )
INFLUXDB_DATABASE = os.environ.get('INFLUXDB_DATABASE', 'simap_telemetry')
INFLUXDB_TOKEN    = os.environ.get('INFLUXDB_TOKEN',    'apiv3_xSq6xD1wBvZ21Pc3uPnqqmgLeSn-kZbz1y4S4u8GtSbJebEly8wl9WUjGJ0Ja_bQuwKB_lpDcHrNJUBCDJMSCw')
Loading