Commit 77bbc83e authored by Sergio Gimenez's avatar Sergio Gimenez
Browse files

Add SRM client configuration

parent cf93d9b3
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@ requests==2.32.4
rpds-py==0.13.2
six==1.16.0
setuptools==80.9.0
sunrise6g-opensdk==1.0.21
swagger-ui-bundle==0.0.9
urllib3==2.1.0
Werkzeug==2.2.3

src/clients/srm.py

0 → 100644
+84 −0
Original line number Diff line number Diff line
# -------------------------------------------------------------------------- #
# Copyright 2025-present, Federation Manager, by Software Networks, i2CAT    #
#                                                                            #
# 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 configparser import ConfigParser
import os

import requests


CONFIG = ConfigParser()
config_file = os.environ.get("FM_CONFIG_FILE", "conf/config.cfg")
CONFIG.read(config_file)
HOST = CONFIG.get("service_resource_manager", "host")
PORT = int(CONFIG.get("service_resource_manager", "port"))
BASE_URL = f"http://{HOST}:{PORT}/srm/1.0.0/internal/fm"


def _request(method, path, json_payload=None):
    return requests.request(method, f"{BASE_URL}{path}", json=json_payload, timeout=30)


def get_list_zones():
    response = _request("GET", "/zones/list")
    return response.json()


def get_zones():
    response = _request("GET", "/zones")
    return response.json()


def get_zone_by_zone_id(zone_id):
    response = _request("GET", f"/zones/{zone_id}")
    if response.status_code == 404:
        return None
    return response.json()


def onboarding_artefact(artefact_data):
    return _request("POST", "/artefacts", artefact_data)


def delete_artefact(artefact_id):
    return _request("DELETE", f"/artefacts/{artefact_id}")


def get_onboarding(app_id):
    return _request("GET", f"/onboardings/{app_id}")


def post_onboarding(onboarding_data):
    return _request("POST", "/onboardings", onboarding_data)


def update_onboarding(app_id, onboarding_data):
    return _request("PATCH", f"/onboardings/{app_id}", onboarding_data)


def delete_onboarding(app_id):
    return _request("DELETE", f"/onboardings/{app_id}")


def post_app_command(deployment_data):
    return _request("POST", "/deployments", deployment_data)


def get_app_by_zone_app_instance_id(app_id, app_instance_id, zone_id):
    return _request("GET", f"/deployments/{app_id}/instances/{app_instance_id}/zones/{zone_id}")


def delete_app(app_id, app_instance_id, zone_id):
    return _request("DELETE", f"/deployments/{app_id}/instances/{app_instance_id}/zones/{zone_id}")
+4 −0
Original line number Diff line number Diff line
@@ -35,6 +35,10 @@ lcmServiceEndPoint_fqdn =
lcmServiceEndPoint_ipv4Addresses = 127.0.0.1
lcmServiceEndPoint_ipv6Addresses =

[service_resource_manager]
host = srm-local
port = 8080

[edge_cloud_platform]
host = lite2edge-local
port = 8080
+4 −0
Original line number Diff line number Diff line
@@ -36,6 +36,10 @@ lcmServiceEndPoint_fqdn =
lcmServiceEndPoint_ipv4Addresses = 127.0.0.1
lcmServiceEndPoint_ipv6Addresses =

[service_resource_manager]
host = srm-remote
port = 8080

[edge_cloud_platform]
host = lite2edge-remote
port = 8080
+4 −0
Original line number Diff line number Diff line
@@ -35,6 +35,10 @@ lcmServiceEndPoint_fqdn =
lcmServiceEndPoint_ipv4Addresses = 127.0.0.1
lcmServiceEndPoint_ipv6Addresses =

[service_resource_manager]
host = 127.0.0.1
port = 8080

[edge_cloud_platform]
host = 192.168.123.237
port = 30769