Commit 9e7f1baf authored by Waleed Akbar's avatar Waleed Akbar
Browse files

Update SIMAP server deployment script and improve main module imports

- Modify deploy.sh to use host-gateway for InfluxDB connection.
- Refactor imports in __main__.py for better readability.
- Adjust sleep duration in main function for performance optimization.
parent b28ee834
Loading
Loading
Loading
Loading
+3 −5
Original line number Original line Diff line number Diff line
@@ -18,15 +18,13 @@
docker rm --force simap-server
docker rm --force simap-server




# Get Docker bridge gateway IP (host accessible from container)
# If needed adjust with actual InfluxDB host IP
DOCKER_HOST_IP=$(ip -4 addr show docker0 2>/dev/null | grep -oP '(?<=inet\s)\d+(\.\d+){3}' || echo "host.docker.internal")

# Create SIMAP Server with InfluxDB configuration
# Create SIMAP Server with InfluxDB configuration
# INFLUXDB_HOST points to the host machine where InfluxDB is running
# INFLUXDB_HOST points to the host machine where InfluxDB is running
# Use --add-host to make the host accessible from inside the container
docker run --detach --name simap-server \
docker run --detach --name simap-server \
    --publish 8080:8080 \
    --publish 8080:8080 \
    --env INFLUXDB_HOST="${DOCKER_HOST_IP}" \
    --add-host=host.docker.internal:host-gateway \
    --env INFLUXDB_HOST="host.docker.internal" \
    --env INFLUXDB_PORT=8181 \
    --env INFLUXDB_PORT=8181 \
    --env INFLUXDB_DATABASE=simap_telemetry \
    --env INFLUXDB_DATABASE=simap_telemetry \
    simap-server:test
    simap-server:test
+5 −3
Original line number Original line Diff line number Diff line
@@ -15,10 +15,11 @@


import json, logging, random, time
import json, logging, random, time
from common.tools.rest_conf.client.RestConfClient import RestConfClient
from common.tools.rest_conf.client.RestConfClient import RestConfClient

from .SimapClient import SimapClient
from .SimapClient import SimapClient
from .SimapMetricsGenerator import SimapMetricsGenerator
from .SimapMetricsGenerator import SimapMetricsGenerator
from .Tools import create_simap_aggnet, create_simap_e2enet, create_simap_te, create_simap_trans
from .Tools import (create_simap_aggnet, create_simap_e2enet, 

                    create_simap_te, create_simap_trans)


logging.basicConfig(level=logging.INFO)
logging.basicConfig(level=logging.INFO)
logging.getLogger('RestConfClient').setLevel(logging.WARN)
logging.getLogger('RestConfClient').setLevel(logging.WARN)
@@ -31,6 +32,7 @@ def main() -> None:
        logger=logging.getLogger('RestConfClient')
        logger=logging.getLogger('RestConfClient')
    )
    )
    simap_client = SimapClient(restconf_client)
    simap_client = SimapClient(restconf_client)
    generator    = SimapMetricsGenerator(service_count=3)


    # ---> Only need to be created once in the lifetime of the SIMAP server <--- #
    # ---> Only need to be created once in the lifetime of the SIMAP server <--- #
    create_simap_te(simap_client)
    create_simap_te(simap_client)
@@ -95,7 +97,7 @@ def main() -> None:
        for link_id, (bw, lat) in abstract_metrics.items():
        for link_id, (bw, lat) in abstract_metrics.items():
            print(f'{link_id:10s}: BW={bw:5.2f}%, Lat={lat:.3f}ms  SvcIDs: {domain_service_map[link_id]}')
            print(f'{link_id:10s}: BW={bw:5.2f}%, Lat={lat:.3f}ms  SvcIDs: {domain_service_map[link_id]}')


        time.sleep(10)
        time.sleep(5)




if __name__ == '__main__':
if __name__ == '__main__':
+2 −2

File changed.

Contains only whitespace changes.