Commit de8b6a59 authored by Waleed Akbar's avatar Waleed Akbar
Browse files

SMO changes

parent 77a7f78d
Loading
Loading
Loading
Loading
+1 −1
Changes for src/tests/ecoc26_pluggables/descriptors/ecoc26_nbi_pluggable_sbi_messages.py: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ def _hub_payload(active_group_ids: Set[int]) -> Dict[str, Any]:
        raise ValueError(f"Unsupported HUB DSC group ids: {sorted(invalid_group_ids)}")

    return {
        "name": "channel-5",
        "name": "channel-7",
        "frequency": "194000000",
        "target_output_power": "0.0",
        "operation": "merge",
+1 −1
Changes for src/tests/ecoc26_pluggables/test_SMO/run_smo_test.sh: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ cd "$(dirname "$0")"
PYTHON="${PYTHON:-python3}"

# Optional overrides (defaults live inside the Python script).
: "${SMO_BASE_URL:=https://hyper-orchestrator.eu}"
: "${SMO_BASE_URL:=http://192.168.5.132:8080}"
: "${SMO_USERNAME:=smo_admin}"
: "${SMO_PASSWORD:=smo_password}"

+73 −16
Changes for src/tests/ecoc26_pluggables/test_SMO/test_SMO_connect.py: 73 added lines, 16 removed lines.
Original line number Diff line number Diff line
@@ -14,9 +14,15 @@ Usage:

Requirements:
    pip install requests

Logs are appended beside this script as test_SMO_connect_YYYY-MM-DD_HH_MM.log.
Each log message includes its execution timestamp (local time).
Only request messages and final statuses are also shown in the terminal.
"""

from datetime import datetime
import json
import logging
import os
import sys
import urllib3
@@ -25,48 +31,88 @@ import requests

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

BASE_URL = os.environ.get("SMO_BASE_URL", "https://hyper-orchestrator.eu")
BASE_URL = os.environ.get("SMO_BASE_URL", "http://192.168.5.132:8080")
USERNAME = os.environ.get("SMO_USERNAME", "smo_admin")
PASSWORD = os.environ.get("SMO_PASSWORD", "smo_password")
SLICE_PATH = "/smo/api/intents/slice"
SLICE_PATH = "/api/intents/slice"
REQUEST_TIMEOUT_SECONDS = 90
INTENT_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_SMO_intent.json")
LOGGER = logging.getLogger(__name__)


def configure_logging():
    """Log details to a file and request/status messages to the terminal."""
    log_file = os.path.join(
        os.path.dirname(os.path.abspath(__file__)),
        f"test_SMO_connect_{datetime.now():%Y-%m-%d_%H_%M}.log",
    )
    console_handler = logging.StreamHandler(sys.stdout)
    console_handler.addFilter(lambda record: getattr(record, "terminal", False))
    logging.basicConfig(
        level=logging.INFO,
        format="%(asctime)s.%(msecs)03d %(levelname)s %(message)s",
        datefmt="%Y-%m-%d %H:%M:%S",
        handlers=[
            logging.FileHandler(log_file, encoding="utf-8"),
            console_handler,
        ],
    )
    LOGGER.info("Log file: %s", log_file)


def create_slice():
    """POST the intent JSON body to create a slice."""
    LOGGER.info("Loading intent from %s", INTENT_FILE)
    with open(INTENT_FILE, "r", encoding="utf-8") as fh:
        payload = json.load(fh)

    url = BASE_URL + SLICE_PATH
    print(f"POST {url}")
    resp = requests.post(url, json=payload, auth=(USERNAME, PASSWORD), verify=False, timeout=30)
    print(f"Status: {resp.status_code}")
    print(resp.text)
    LOGGER.info("POST %s", url, extra={"terminal": True})
    resp = requests.post(
        url,
        json=payload,
        auth=(USERNAME, PASSWORD),
        verify=False,
        timeout=REQUEST_TIMEOUT_SECONDS,
    )
    LOGGER.info("Status: %s", resp.status_code, extra={"terminal": True})
    LOGGER.info("%s", resp.text)
    return resp


def list_slices():
    """GET the list of slices."""
    url = BASE_URL + SLICE_PATH
    print(f"GET {url}")
    resp = requests.get(url, auth=(USERNAME, PASSWORD), verify=True, timeout=30)
    print(f"Status: {resp.status_code}")
    print(resp.text)
    LOGGER.info("GET %s", url, extra={"terminal": True})
    resp = requests.get(
        url,
        auth=(USERNAME, PASSWORD),
        verify=True,
        timeout=REQUEST_TIMEOUT_SECONDS,
    )
    LOGGER.info("Status: %s", resp.status_code, extra={"terminal": True})
    LOGGER.info("%s", resp.text)
    return resp


def delete_slice(slice_id):
    """DELETE a slice by its id."""
    url = f"{BASE_URL}{SLICE_PATH}/{slice_id}"
    print(f"DELETE {url}")
    resp = requests.delete(url, auth=(USERNAME, PASSWORD), verify=False, timeout=30)
    print(f"Status: {resp.status_code}")
    print(resp.text)
    LOGGER.info("DELETE %s", url, extra={"terminal": True})
    resp = requests.delete(
        url,
        auth=(USERNAME, PASSWORD),
        verify=False,
        timeout=REQUEST_TIMEOUT_SECONDS,
    )
    LOGGER.info("Status: %s", resp.status_code, extra={"terminal": True})
    LOGGER.info("%s", resp.text)
    return resp


if __name__ == "__main__":
def main():
    action = sys.argv[1] if len(sys.argv) > 1 else "all"
    LOGGER.info("Starting action: %s", action)

    if action == "all":
        create_slice()
@@ -79,5 +125,16 @@ if __name__ == "__main__":
        slice_id = sys.argv[2] if len(sys.argv) > 2 else "slice"
        delete_slice(slice_id)
    else:
        print(f"Unknown action: {action}", file=sys.stderr)
        LOGGER.error("Unknown action: %s", action, extra={"terminal": True})
        sys.exit(1)
    LOGGER.info("Completed action: %s", action)


if __name__ == "__main__":
    configure_logging()
    try:
        main()
    except Exception:
        LOGGER.exception("SMO execution failed")
        LOGGER.error("Status: failed; see log file for details", extra={"terminal": True})
        sys.exit(1)
+42 −17
Changes for src/tests/ecoc26_pluggables/test_SMO/test_SMO_intent.json: 42 added lines, 17 removed lines.
Original line number Diff line number Diff line
{
    "intentId": "intent-slice5v1",
    "metadata": {
    "sliceId": "slice",
        "sliceId": "slice5v1",
        "description": "example slice5v1",
        "serviceTags": ["L3"],
        "endpoints": [
            {
                "id": "T1.1",
                "node": "PE-A",
                "role": "spoke",
                "ipv4": "192.0.2.1/26",
        "interface": "GigabitEthernet5/0/0/2",
                "vlan": "100",
        "role": "ietf-vpn-common:spoke-role"
                "interface": "GigabitEthernet5/0/0/2",
                "acId": "acT1.1",
                "acDescription": "ACT1.1 connected to device T1.1",
                "acNodeId": "PE-A"
            },
            {
                "id": "T1.2",
                "node": "PE-A",
        "ipv4": "198.51.100.1/26",
        "interface": "GigabitEthernet7/0/0/5",
        "vlan": "200",
        "role": "ietf-vpn-common:spoke-role"
                "role": "spoke",
                "ipv4": "192.0.2.1/26",
                "vlan": "100",
                "interface": "GigabitEthernet5/0/0/2",
                "acId": "acT1.2",
                "acDescription": "ACT1.2 connected to device T1.2",
                "acNodeId": "PE-A"
            },
            {
                "id": "T1.3",
                "node": "PE-B",
                "role": "spoke",
                "ipv4": "192.0.2.65/26",
        "interface": "GigabitEthernet8/0/0/6",
                "vlan": "101",
        "role": "ietf-vpn-common:spoke-role"
                "interface": "GigabitEthernet8/0/0/6",
                "acId": "acT1.3",
                "acDescription": "AC13a connected to device T1.3",
                "acNodeId": "PE-B"
            },
            {
                "id": "T2.1",
                "node": "PE-C",
                "role": "hub",
                "ipv4": "192.0.2.129/26",
        "interface": "GigabitEthernet4/0/0/3",
                "vlan": "100",
        "role": "ietf-vpn-common:hub-role"
                "interface": "GigabitEthernet4/0/0/3",
                "acId": "acT2.1",
                "acDescription": "AC2.1 connected to device T2.1",
                "acNodeId": "PE-C"
            }
        ]
    },
    "objectives": {
    "bandwidth": {
      "bound": "1000"
    },
    "latency": {
      "bound": "100"
        "sla": {
            "description": "video-policy",
            "bandwidth": {"bound": "1000", "metric-unit": "Mbps"},
            "latency": {"bound": "100", "metric-unit": "milliseconds", "type": "two-way-delay-maximum"},
            "availability": "three-nines",
            "mtu": 1500
        },
        "connectivity": {
      "type": "hub-spoke"
            "id": "matrix5",
            "type": "hub-spoke",
            "constructs": [
                {
                    "id": "1",
                    "sender": "T2.1",
                    "receivers": ["T1.1"],
                    "latency": {"bound": "10", "metric-unit": "milliseconds", "type": "one-way-delay-maximum"}
                }
            ]
        }
    }
}
 No newline at end of file