Commit 67926e68 authored by JorgeEcheva26's avatar JorgeEcheva26
Browse files

lowcase variables

parent a379a263
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -15,8 +15,8 @@
    "csr_email_address": "test@example.com",
    "capif_username": "echeva_0",
    "capif_password": "echevapass",
    "APFs": "1",
    "AEFs": "2",
    "apfs": "1",
    "aefs": "2",
    "debug_mode": "True",
    "discover_filter" : {
        "api-name": "",
@@ -34,9 +34,9 @@
        "service-kpis": ""
      },
    "publish_req" : {
        "serviceApiId":"addd0af19a424e54c87fc8b1fe4fba",
        "publisherAPFid":"APFd7feeefab02e127ec6817e7cda9ac7",
        "publisherAEFsids":["AEFb1f5ab26a98e3c24d5dfad26507a28","AEFb0fa4e048bea75f0f335cfa8b2a0aa"]
        "service_api_id":"addd0af19a424e54c87fc8b1fe4fba",
        "publisher_apf_id":"APFd7feeefab02e127ec6817e7cda9ac7",
        "publisher_aefs_ids":["AEFb1f5ab26a98e3c24d5dfad26507a28","AEFb0fa4e048bea75f0f335cfa8b2a0aa"]
    },
    "api_description_path":""
}
 No newline at end of file
+5 −5
Original line number Diff line number Diff line
@@ -31,9 +31,9 @@ This file could also be fullfilled by [enviroment variables](../samples/envirome

- capif_password: CAPIF password 

- APFs: Number of APF's you want to onboard as a provider Example:5 
- apfs: Number of APF's you want to onboard as a provider Example:5 

- AEFs: Number of AEF's you want to onboard as a provider Example:2
- aefs: Number of AEF's you want to onboard as a provider Example:2

- debug_mode: Boolean | If you want to recieve logs from SDK Example:True/False

@@ -80,9 +80,9 @@ To run the Invoker Service Discovery Functionality it has to be onboarded as an

This configuration fields is only mandatory if we want to use the [CAPIF_Publish_Service_API](https://github.com/jdegre/5GC_APIs/blob/Rel-18/TS29222_CAPIF_Publish_Service_API.yaml) 

   - serviceApiId: The Api id we want to use Example "02eff6e1b3a8f7c8044a92ee8a30bd"
   - publisherAPFid: APF id we chose to use Example : "APFa165364a379035d14311deadc04332"
   - publisherAEFsids: Array of strings filled out of AEFs ids we want to use Example:        ["AEFfa38f0e855bffb420e4994ecbc8fb9","AEFe8bfa711f4f0c95ba0b382508e6382"]
   - service_api_id: The Api id we want to use Example "02eff6e1b3a8f7c8044a92ee8a30bd"
   - publisher_apf_id: APF id we chose to use Example : "APFa165364a379035d14311deadc04332"
   - publisher_aefs_ids: Array of strings filled out of AEFs ids we want to use Example:        ["AEFfa38f0e855bffb420e4994ecbc8fb9","AEFe8bfa711f4f0c95ba0b382508e6382"]

For using the Publish Api function or the Update function the provider_api_description_sample.json **must** have been  modified with the Publish API that is wanted to share following the standard schema for [ServiceAPIDescription](https://github.com/jdegre/5GC_APIs/blob/Rel-18/TS29222_CAPIF_Publish_Service_API.yaml)

+44 −44
Original line number Diff line number Diff line
@@ -509,8 +509,8 @@ class CAPIFProviderConnector:
            csr_state_or_province_name = os.getenv('CSR_STATE_OR_PROVINCE_NAME', config.get('csr_state_or_province_name', '')).strip()
            csr_country_name = os.getenv('CSR_COUNTRY_NAME', config.get('csr_country_name', '')).strip()
            csr_email_address = os.getenv('CSR_EMAIL_ADDRESS', config.get('csr_email_address', '')).strip()
            APFs = os.getenv('APFS', config.get('APFs', '')).strip()
            AEFs = os.getenv('AEFS', config.get('AEFs', '')).strip()
            apfs = os.getenv('APFS', config.get('apfs', '')).strip()
            aefs = os.getenv('AEFS', config.get('aefs', '')).strip()
            api_description_path = os.getenv('API_DESCRIPTION_PATH', config.get('api_description_path', '')).strip()

            if not capif_host:
@@ -534,8 +534,8 @@ class CAPIFProviderConnector:
            self.csr_state_or_province_name = csr_state_or_province_name
            self.csr_country_name = csr_country_name
            self.csr_email_address = csr_email_address
            self.AEFs = int(AEFs)
            self.APFs = int(APFs)
            self.aefs = int(aefs)
            self.apfs = int(apfs)
            self.api_description_path=api_description_path
            
            self.capif_https_port = str(capif_https_port)
@@ -640,10 +640,10 @@ class CAPIFProviderConnector:

        # Crear la lista de roles sin indexar
        roles = ["AMF"]
        for n in range(1, self.AEFs + 1):
        for n in range(1, self.aefs + 1):
            roles.append("AEF")

        for n in range(1, self.APFs + 1):
        for n in range(1, self.apfs + 1):
            roles.append("APF")

        # Construir el payload con los roles sin indexar
@@ -660,10 +660,10 @@ class CAPIFProviderConnector:

        # Generar los roles indexados para la creación de certificados
        indexedroles = ["AMF"]
        for n in range(1, self.AEFs + 1):
        for n in range(1, self.aefs + 1):
            indexedroles.append(f"AEF-{n}")

        for n in range(1, self.APFs + 1):
        for n in range(1, self.apfs + 1):
            indexedroles.append(f"APF-{n}")

        # Guardar las claves públicas y generar los certificados con roles indexados
@@ -695,10 +695,10 @@ class CAPIFProviderConnector:

        # Generar los roles indexados para la correspondencia
        indexedroles = ["AMF"]
        for n in range(1, self.AEFs + 1):
        for n in range(1, self.aefs + 1):
            indexedroles.append(f"AEF-{n}")

        for n in range(1, self.APFs + 1):
        for n in range(1, self.apfs + 1):
            indexedroles.append(f"APF-{n}")

        # Guardar los certificados con los nombres indexados
@@ -807,8 +807,8 @@ class CAPIFProviderConnector:
        
        chosenAPFsandAEFs=chosenAPFsandAEFs["publish_req"]

        APF_api_prov_func_id = chosenAPFsandAEFs["publisherAPFid"]
        AEFs_list = chosenAPFsandAEFs["publisherAEFsids"]
        APF_api_prov_func_id = chosenAPFsandAEFs["publisher_apf_id"]
        AEFs_list = chosenAPFsandAEFs["publisher_aefs_ids"]

        apf_number = None
        for key, value in provider_details.items():
@@ -818,8 +818,8 @@ class CAPIFProviderConnector:
                break

        if apf_number is None:
            self.logger.error(f"No matching APF found for publisherAPFid: {APF_api_prov_func_id}")
            raise ValueError("Invalid publisherAPFid")
            self.logger.error(f"No matching APF found for publisher_apf_id: {APF_api_prov_func_id}")
            raise ValueError("Invalid publisher_apf_id")
        service_api_description_json_full_path = self.api_description_path
        # Leer y modificar la descripción de la API de servicio
        self.logger.info(f"Reading and modifying service API description from {service_api_description_json_full_path}")
@@ -830,7 +830,7 @@ class CAPIFProviderConnector:

                # Verificamos que el número de AEFs coincide con el número de perfiles
                if len(AEFs_list) != len(data.get("aefProfiles", [])):
                    self.logger.error("The number of AEFs in publisherAEFsids does not match the number of profiles in aefProfiles")
                    self.logger.error("The number of AEFs in publisher_aefs_ids does not match the number of profiles in aefProfiles")
                    raise ValueError("Mismatch between number of AEFs and profiles")

                # Asignamos los AEFs correspondientes
@@ -932,9 +932,9 @@ class CAPIFProviderConnector:
        with open(json_path, 'r') as f:
            publish = json.load(f)
        publish=publish["publish_req"]
        api_id="/" + publish["serviceApiId"]
        APF_api_prov_func_id=publish["publisherAPFid"]
        AEFs_list = publish["publisherAEFsids"]
        api_id="/" + publish["service_api_id"]
        APF_api_prov_func_id=publish["publisher_apf_id"]
        AEFs_list = publish["publisher_aefs_ids"]
        apf_number = None
        for key, value in provider_details.items():
            if value == APF_api_prov_func_id and key.startswith("APF-"):
@@ -943,8 +943,8 @@ class CAPIFProviderConnector:
                break

        if apf_number is None:
            self.logger.error(f"No matching APF found for publisherAPFid: {APF_api_prov_func_id}")
            raise ValueError("Invalid publisherAPFid")
            self.logger.error(f"No matching APF found for publisher_apf_id: {APF_api_prov_func_id}")
            raise ValueError("Invalid publisher_apf_id")

        
        self.logger.info(f"Loading provider details from {provider_details_path}")
@@ -977,7 +977,7 @@ class CAPIFProviderConnector:
                
                # Verificar si el archivo empieza con 'CAPIF-'

                if filename.startswith("CAPIF-") and publish["serviceApiId"] in filename:
                if filename.startswith("CAPIF-") and publish["service_api_id"] in filename:
                    
                    os.remove(path) # Salir del bucle si el archivo es eliminado
                    break
@@ -991,7 +991,7 @@ class CAPIFProviderConnector:
                    published_apis = json.load(outfile)

            # ID del API que deseas eliminar
            api_id_to_delete = publish["serviceApiId"]  # Reemplaza con el ID específico
            api_id_to_delete = publish["service_api_id"]  # Reemplaza con el ID específico

            # Buscar y eliminar el API por su ID
            api_name_to_delete = None
@@ -1045,9 +1045,9 @@ class CAPIFProviderConnector:

        chosenAPFsandAEFs=chosenAPFsandAEFs["publish_req"]

        APF_api_prov_func_id = chosenAPFsandAEFs["publisherAPFid"]
        APF_api_prov_func_id = chosenAPFsandAEFs["publisher_apf_id"]
        
        api_id="/" +chosenAPFsandAEFs["serviceApiId"]
        api_id="/" +chosenAPFsandAEFs["service_api_id"]
        
        apf_number = None
        for key, value in provider_details.items():
@@ -1057,8 +1057,8 @@ class CAPIFProviderConnector:
                break

        if apf_number is None:
            self.logger.error(f"No matching APF found for publisherAPFid: {APF_api_prov_func_id}")
            raise ValueError("Invalid publisherAPFid")
            self.logger.error(f"No matching APF found for publisher_apf_id: {APF_api_prov_func_id}")
            raise ValueError("Invalid publisher_apf_id")

        url = f"{self.capif_https_url}{publish_url.replace('<apfId>', APF_api_prov_func_id)}{api_id}"

@@ -1123,7 +1123,7 @@ class CAPIFProviderConnector:
        
        chosenAPFsandAEFs=chosenAPFsandAEFs["publish_req"]

        APF_api_prov_func_id = chosenAPFsandAEFs["publisherAPFid"]
        APF_api_prov_func_id = chosenAPFsandAEFs["publisher_apf_id"]
        

        apf_number = None
@@ -1134,8 +1134,8 @@ class CAPIFProviderConnector:
                break

        if apf_number is None:
            self.logger.error(f"No matching APF found for publisherAPFid: {APF_api_prov_func_id}")
            raise ValueError("Invalid publisherAPFid")
            self.logger.error(f"No matching APF found for publisher_apf_id: {APF_api_prov_func_id}")
            raise ValueError("Invalid publisher_apf_id")

        # Leer y modificar la descripción de la API de servicio
        
@@ -1205,8 +1205,8 @@ class CAPIFProviderConnector:

        chosenAPFsandAEFs=chosenAPFsandAEFs["publish_req"]

        APF_api_prov_func_id = chosenAPFsandAEFs["publisherAPFid"]
        AEFs_list = chosenAPFsandAEFs["publisherAEFsids"]
        APF_api_prov_func_id = chosenAPFsandAEFs["publisher_apf_id"]
        AEFs_list = chosenAPFsandAEFs["publisher_aefs_ids"]

        apf_number = None
        for key, value in provider_details.items():
@@ -1216,8 +1216,8 @@ class CAPIFProviderConnector:
                break

        if apf_number is None:
            self.logger.error(f"No matching APF found for publisherAPFid: {APF_api_prov_func_id}")
            raise ValueError("Invalid publisherAPFid")
            self.logger.error(f"No matching APF found for publisher_apf_id: {APF_api_prov_func_id}")
            raise ValueError("Invalid publisher_apf_id")

        service_api_description_json_full_path = self.api_description_path
        # Leer y modificar la descripción de la API de servicio
@@ -1229,7 +1229,7 @@ class CAPIFProviderConnector:

                # Verificamos que el número de AEFs coincide con el número de perfiles
                if len(AEFs_list) != len(data.get("aefProfiles", [])):
                    self.logger.error("The number of AEFs in publisherAEFsids does not match the number of profiles in aefProfiles")
                    self.logger.error("The number of AEFs in publisher_aefs_ids does not match the number of profiles in aefProfiles")
                    raise ValueError("Mismatch between number of AEFs and profiles")

                # Asignamos los AEFs correspondientes
@@ -1251,7 +1251,7 @@ class CAPIFProviderConnector:
        except ValueError as e:
            self.logger.error(f"Error with the input data: {e}")
            raise
        api_id="/" +chosenAPFsandAEFs["serviceApiId"]
        api_id="/" +chosenAPFsandAEFs["service_api_id"]
        # Publish services
        url = f"{self.capif_https_url}{publish_url.replace('<apfId>', APF_api_prov_func_id)}{api_id}"
        cert = (
@@ -1452,8 +1452,8 @@ class CAPIFProviderConnector:
        AEFscertstoremove = 0
        AEFscertstoadd = 0
        # Calcula la diferencia de APFs
        if apf_count != self.APFs:
            diff = apf_count - self.APFs
        if apf_count != self.apfs:
            diff = apf_count - self.apfs
            if diff < 0:
                self.APFscertstoadd = abs(diff)
            else:
@@ -1463,8 +1463,8 @@ class CAPIFProviderConnector:
            APFscertstoadd = 0

        # Calcula la diferencia de AEFs
        if aef_count != self.AEFs:
            diff = aef_count - self.AEFs
        if aef_count != self.aefs:
            diff = aef_count - self.aefs
            if diff < 0:
                self.AEFscertstoadd = abs(diff)
            else:
@@ -1475,7 +1475,7 @@ class CAPIFProviderConnector:

        # Eliminar ficheros APF en orden descendente si hay más APFs de los que debería haber
        if APFscertstoremove:
            while apf_count > self.APFs:
            while apf_count > self.apfs:
                # List files starting with "APF-" or "apf-" in the directory
                file_path = os.path.join(self.provider_folder, f"APF-{apf_count}_private_key.key")
                os.remove(file_path)
@@ -1500,7 +1500,7 @@ class CAPIFProviderConnector:

        # Remove AEF files in descending order if there are more AEFs than there should be
        if AEFscertstoremove:
            while aef_count > self.AEFs:
            while aef_count > self.aefs:
                # List files starting with "AEF-" or "aef-" in the directory
                file_path = os.path.join(self.provider_folder, f"AEF-{aef_count}_private_key.key")
                os.remove(file_path)
@@ -1532,10 +1532,10 @@ class CAPIFProviderConnector:

        # Crear la lista de roles sin indexar
        roles = ["AMF"]
        for n in range(1, self.AEFs + 1):
        for n in range(1, self.aefs + 1):
            roles.append("AEF")

        for n in range(1, self.APFs + 1):
        for n in range(1, self.apfs + 1):
            roles.append("APF")

        # Construir el payload con los roles sin indexar
@@ -1551,7 +1551,7 @@ class CAPIFProviderConnector:
        }

        # Generar los roles indexados para la creación de certificados
        indexed_roles = ["AMF"] + [f"AEF-{n}" for n in range(1, self.AEFs + 1)] + [f"APF-{n}" for n in range(1, self.APFs + 1)]
        indexed_roles = ["AMF"] + [f"AEF-{n}" for n in range(1, self.aefs + 1)] + [f"APF-{n}" for n in range(1, self.apfs + 1)]

        # Recorrer cada función de proveedor de API
        for i, api_func in enumerate(payload["apiProvFuncs"]):