Commit f9e7001d authored by Paris Stentoumis's avatar Paris Stentoumis
Browse files

adding artefactData on tf_sdk.post_onboarding call only when client is kubernetes

parent c2e7b78e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ requests==2.32.4
rpds-py==0.13.2
six==1.16.0
setuptools==80.9.0
sunrise6g-opensdk==1.0.21
#sunrise6g-opensdk==1.0.21
swagger-ui-bundle==0.0.9
urllib3==2.1.0
Werkzeug==2.2.3
+7 −1
Original line number Diff line number Diff line
@@ -142,7 +142,13 @@ def onboard_application(body, federation_context_id, bearer_token=None, partner_

    # Create onboarding at Edge Cloud Platform
    try:
        response = tf_sdk.post_onboarding(body.to_gsma_input())
        originating_am_objects : OriginatingArtefactManagement = OriginatingArtefactManagement.objects(
            orig_am_federation_context_id=federation_context_id,
            orig_am_artefact_id=body.app_id)
        onboarding_data = body.to_gsma_input()
        onboarding_data.update({"artefactData": originating_am_objects[0].to_mongo().to_dict()})
        
        response = tf_sdk.post_onboarding(onboarding_data)
        if response.status_code == 200:
            # Convert the original model instance to the MongoEngine document
            onboarding_data = fill_application_onboarding_mongo_document(federation_context_id, body)
+10 −1
Original line number Diff line number Diff line
@@ -48,6 +48,9 @@ class EdgeCloudClient:

        self.host = host
        self.port = port
        if client_name == "kubernetes":
            self.base_url = f"https://{host}:{port}"
        else:
            self.base_url = f"http://{host}:{port}"
        self.client_name = client_name

@@ -58,6 +61,10 @@ class EdgeCloudClient:
                "flavour_id": FLAVOUR_ID
            }
        }
        #Consider changing this to only load the necessary variables from
        # the config file
        if client_name == "kubernetes":
            client_specs["edgecloud"].update(os.environ)

        try:
            clients = sdkclient.create_adapters_from(client_specs)
@@ -125,6 +132,8 @@ class EdgeCloudClient:
    def post_onboarding(self, onboarding_data):
        """Create application onboarding using GSMA-compliant API"""
        try:
            if self.client_name != "kubernetes":
                onboarding_data.pop("artefactData")
            return self.edgecloud_client.onboard_app_gsma(onboarding_data)
        except Exception as e:
            logger.error(f"Error creating onboarding: {e}")