Commit 7b2e189d authored by Pablo Armingol's avatar Pablo Armingol
Browse files

Update NSC_PORT to 8086 and remove unused constants from the project

parent a0522de7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
from pathlib import Path

# Default port for NSC deployment
NSC_PORT = 8081
NSC_PORT = 8086

# Paths
BASE_DIR = Path(__file__).resolve().parent.parent.parent

src/constants.py

deleted100644 → 0
+0 −62
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.

# This file is an original contribution from Telefonica Innovación Digital S.L.
""" This file contains constants used throughout the NSC application. """

<<<<<<<< HEAD:src/utils/dump_templates.py
import json, os
from src.config.constants import TEMPLATES_PATH
from flask import current_app

def dump_templates(nbi_file, ietf_file, realizer_file):
    """
    Dump multiple templates as JSON into the templates path.
    """
    if not current_app.config["DUMP_TEMPLATES"]:
        return
========
import logging
import os
# Default logging level
DEFAULT_LOGGING_LEVEL = logging.INFO

# Default port for NSC deployment
NSC_PORT = 8086
>>>>>>>> 1c9c24fe98b87f87d11c79af0904b705c97a9ded:src/constants.py

    templates = {
        "nbi_template.json": nbi_file,
        "ietf_template.json": ietf_file,
        "realizer_template.json": realizer_file,
    }

<<<<<<<< HEAD:src/utils/dump_templates.py
    for filename, content in templates.items():
        path = os.path.join(TEMPLATES_PATH, filename)
        with open(path, "w") as f:
            json.dump(content, f, indent=2)
========
# Create the path to the desired file relative to the current file
TEMPLATES_PATH = os.path.join(SRC_PATH, "templates")

# TFS Flags
# Flag to determine if configurations should be uploaded to Teraflow
TFS_UPLOAD = False
# Teraflow IP
TFS_IP = "10.95.86.58"
# Flag to determine if additional L2VPN configuration support is
# required for deploying L2VPNs with path selection
TFS_L2VPN_SUPPORT = False
>>>>>>>> 1c9c24fe98b87f87d11c79af0904b705c97a9ded:src/constants.py
+0 −52
Original line number Diff line number Diff line
@@ -13,64 +13,12 @@
# limitations under the License.
""" This file is an original contribution from Telefonica Innovación Digital S.L. """

<<<<<<< HEAD:src/realizer/tfs/helpers/cisco_connector.py
# This file is an original contribution from Telefonica Innovación Digital S.L.

import logging
from netmiko import ConnectHandler

class cisco_connector():
=======
import json
import logging
import os
import uuid
import requests
from netmiko import ConnectHandler
from src.constants import DEFAULT_LOGGING_LEVEL

logging.basicConfig(
    level=DEFAULT_LOGGING_LEVEL,
    format='%(levelname)s - %(message)s')

#Teraflow
class TFSConnector():
    """Connector class for interacting with Teraflow SDN.
       This class provides methods to send requests to
       Teraflow SDN for network service configuration."""

    def simple_post(self, tfs_ip, service):
        """Send a simple POST request to Teraflow SDN.
           This method sends a JSON payload to the Teraflow SDN
           service endpoint to configure network services."""

        user="admin"
        password="admin"
        token=""
        session = requests.Session()
        session.auth = (user, password)
        url=f'http://{tfs_ip}/webui'
        response=session.get(url=url)
        for item in response.iter_lines():
            if "csrf_token" in str(item):
                string=str(item).split('<input id="csrf_token" name="csrf_token" type="hidden" value=')[1]
                token=string.split(">")[0].strip('"')
        logging.debug("csrf token %s",token)

        files = {'descriptors': ("data.json", json.dumps(service).encode(
                                                                     "utf-8"), "application/json")}
        token={'csrf_token':token}
        response = session.post(url,files=files,data=token,timeout=60)
        logging.debug("Http response: %s",response.text)
        return response

#CISCO
class CiscoConnector():
    """Connector class for interacting with Cisco devices.
       This class provides methods to execute configuration commands
       on Cisco devices via SSH."""

>>>>>>> 1c9c24fe98b87f87d11c79af0904b705c97a9ded:src/helpers.py
    def __init__(self, address, configs=None):
        self.address=address
        self.configs=configs
+0 −23
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@
# This file is an original contribution from Telefonica Innovación Digital S.L.
""" This file contains constants used throughout the NSC application. """

<<<<<<<< HEAD:src/utils/dump_templates.py
import json, os
from src.config.constants import TEMPLATES_PATH
from flask import current_app
@@ -26,15 +25,7 @@ def dump_templates(nbi_file, ietf_file, realizer_file):
    """
    if not current_app.config["DUMP_TEMPLATES"]:
        return
========
import logging
import os
# Default logging level
DEFAULT_LOGGING_LEVEL = logging.INFO

# Default port for NSC deployment
NSC_PORT = 8086
>>>>>>>> 1c9c24fe98b87f87d11c79af0904b705c97a9ded:src/constants.py

    templates = {
        "nbi_template.json": nbi_file,
@@ -42,21 +33,7 @@ NSC_PORT = 8086
        "realizer_template.json": realizer_file,
    }

<<<<<<<< HEAD:src/utils/dump_templates.py
    for filename, content in templates.items():
        path = os.path.join(TEMPLATES_PATH, filename)
        with open(path, "w") as f:
            json.dump(content, f, indent=2)
========
# Create the path to the desired file relative to the current file
TEMPLATES_PATH = os.path.join(SRC_PATH, "templates")

# TFS Flags
# Flag to determine if configurations should be uploaded to Teraflow
TFS_UPLOAD = False
# Teraflow IP
TFS_IP = "10.95.86.58"
# Flag to determine if additional L2VPN configuration support is
# required for deploying L2VPNs with path selection
TFS_L2VPN_SUPPORT = False
>>>>>>>> 1c9c24fe98b87f87d11c79af0904b705c97a9ded:src/constants.py