Commit 9b77d487 authored by Sergio Gimenez's avatar Sergio Gimenez
Browse files

fix(edgecloud): align adapters with smoke flows

parent 33a5a622
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -8,3 +8,4 @@ __pycache__/
.tar.gz
/dist
src/sunrise6g_opensdk.egg-info/
.data/
+236 −479

File changed.

Preview size limit exceeded, changes collapsed.

+18 −0
Original line number Diff line number Diff line
@@ -194,4 +194,22 @@ def deploy_service_function(
        return env_result

    response = kubernetes_connector.deploy_service_function(final_deploy_descriptor)
    deployed_service_function_db = {}
    deployed_service_function_db["service_function_name"] = ser_function_[0]["name"]
    if service_function.location is not None:
        deployed_service_function_db["location"] = service_function.location
    deployed_service_function_db["instance_name"] = deployed_name

    if "volumes" in final_deploy_descriptor:
        deployed_service_function_db["volumes"] = final_deploy_descriptor["volumes"]
    if "env_parameters" in final_deploy_descriptor:
        deployed_service_function_db["env_parameters"] = final_deploy_descriptor["env_parameters"]

    if "location" not in deployed_service_function_db:
        deployed_service_function_db["location"] = "Node is selected by the K8s scheduler"
    if type(response) is V1Deployment and hasattr(connector_db, "insert_document_deployed_service_function"):
        deployed_service_function_db["_id"] = response.metadata.uid
        connector_db.insert_document_deployed_service_function(
            document=deployed_service_function_db
        )
    return response
+3 −0
Original line number Diff line number Diff line
import re


def equal_ignore_order(a, b):
    """Use only when elements are neither hashable nor sortable!"""
    unmatched = list(b)
+28 −0
Original line number Diff line number Diff line
@@ -153,6 +153,18 @@ class ConnectorDB:
        result = mycol.insert_one(insert_doc)
        return result

    def insert_document(self, collection, document=None, unique_field="_id"):
        myclient = pymongo.MongoClient(self._storage_url)
        mydbmongo = myclient[self.mydb_mongo]
        mycol = mydbmongo[collection]

        if unique_field and document.get(unique_field) is not None:
            mydoc = mycol.find_one({unique_field: document[unique_field]})
            if mydoc is not None:
                return f"Document already exists in {collection}"

        return mycol.insert_one(document)

    # ##TODO!!!!!
    # def update_document_service_function(document=None, _id=None):

@@ -198,6 +210,22 @@ class ConnectorDB:
        except Exception as ce_:
            raise Exception("An exception occurred :", ce_)

    def delete_document(self, collection, _id: str = None):
        myclient = pymongo.MongoClient(self._storage_url)
        mydbmongo = myclient[self.mydb_mongo]
        mycol = mydbmongo[collection]

        myquery = {"_id": _id}
        mydoc = mycol.find_one(myquery)

        if mydoc is None:
            return f"Document not found in {collection}", 404
        try:
            mycol.delete_one(myquery)
            return "Document deleted successfully", 200
        except Exception as ce_:
            raise Exception("An exception occurred :", ce_)

    def delete_document_paas_service(self, paas_service_input_name=None, _id=None):
        collection = "paas_services"
        myclient = pymongo.MongoClient(self._storage_url)
Loading