Commit 19bed7bf authored by Adrian Pino's avatar Adrian Pino
Browse files

Satisfy linters

parent 364ef7f5
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -36,14 +36,14 @@ class EdgeApplicationManager(EdgeCloudManagementInterface):
        kubernetes_port = kwargs.get("KUBERNETES_MASTER_PORT")
        storage_uri = kwargs.get("EMP_STORAGE_URI")
        username = kwargs.get("KUBERNETES_USERNAME")
        namespace = kwargs.get('K8S_NAMESPACE')
        namespace = kwargs.get("K8S_NAMESPACE")
        if base_url is not None and base_url != "":
            self.k8s_connector = KubernetesConnector(
                ip=self.kubernetes_host,
                port=kubernetes_port,
                token=kubernetes_token,
                username=username,
                namespace=namespace
                namespace=namespace,
            )
        if storage_uri is not None:
            self.connector_db = ConnectorDB(storage_uri)
+20 −11
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ class KubernetesConnector:
        master_node_ip = ip
        master_node_port = port
        username = username
        self.namespace = 'default' if namespace is None else namespace
        self.namespace = "default" if namespace is None else namespace
        self.token_k8s = token
        if port is None:
            self.host = master_node_ip
@@ -293,7 +293,9 @@ class KubernetesConnector:
                    try:
                        url = (
                            self.host
                            + "/api/v1/namespaces/"+self.namespace+"/persistentvolumeclaims"
                            + "/api/v1/namespaces/"
                            + self.namespace
                            + "/persistentvolumeclaims"
                        )
                        body_volume = self.create_pvc_dict(
                            descriptor_service_function["name"], volume
@@ -305,8 +307,9 @@ class KubernetesConnector:
                    except requests.exceptions.HTTPError as e:
                        # logging.error(traceback.format_exc())
                        return (
                            "Exception when calling CoreV1Api->/api/v1/namespaces/"+self.namespace+"/persistentvolumeclaims: %s\n"
                            % e
                            "Exception when calling CoreV1Api->/api/v1/namespaces/"
                            + self.namespace
                            + "/persistentvolumeclaims: %s\n" % e
                        )

                # api_response_pvc = api_instance_corev1api.create_namespaced_persistent_volume_claim
@@ -579,8 +582,8 @@ class KubernetesConnector:

        return body

    def create_pvc_dict(self,
        name, volumes, storage_class="microk8s-hostpath", volume_name=None
    def create_pvc_dict(
        self, name, volumes, storage_class="microk8s-hostpath", volume_name=None
    ):
        name_vol = name + str("-") + volumes["name"]
        # body={}
@@ -715,7 +718,9 @@ class KubernetesConnector:
        return body

    def get_deployed_dataspace_connector(self, instance_name):
        api_response = self.api_instance_appsv1.list_namespaced_deployment(self.namespace)
        api_response = self.api_instance_appsv1.list_namespaced_deployment(
            self.namespace
        )

        api_response_service = self.v1.list_namespaced_service(self.namespace)
        app_ = {}
@@ -772,9 +777,13 @@ class KubernetesConnector:

    def get_deployed_service_functions(self, connector_db: ConnectorDB):
        self.get_deployed_hpas(connector_db)
        api_response = self.api_instance_appsv1.list_namespaced_deployment(self.namespace)
        api_response = self.api_instance_appsv1.list_namespaced_deployment(
            self.namespace
        )
        api_response_service = self.v1.list_namespaced_service(self.namespace)
        api_response_pvc = self.v1.list_namespaced_persistent_volume_claim(self.namespace)
        api_response_pvc = self.v1.list_namespaced_persistent_volume_claim(
            self.namespace
        )

        apps_col = connector_db.get_documents_from_collection(
            collection_input="service_functions"
@@ -817,8 +826,8 @@ class KubernetesConnector:
        for app_col in apps_col:
            if actual_name == app_col["name"]:
                app_["service_function_catalogue_name"] = app_col["name"]
                app_['appId'] = app_col['_id']
                app_['appProvider'] = app_col.get('appProvider')
                app_["appId"] = app_col["_id"]
                app_["appProvider"] = app_col.get("appProvider")
                break

        # find volumes!
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ test_cases = [
            # "KUBERNETES_MASTER_PORT": "80",
            "KUBERNETES_USERNAME": "user",
            "EMP_STORAGE_URI": "mongodb://146.124.106.200:32411",
            "K8S_NAMESPACE": "sunrise6g"
            "K8S_NAMESPACE": "sunrise6g",
        }
    },
]
+1 −1
Original line number Diff line number Diff line
@@ -124,7 +124,7 @@ CONFIG = {
    "kubernetes": {
        "K8S_ONBOARDED_APP_NAME": "nginx",
        "K8S_APP_ID": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
        'ZONE_ID': '999b7746-d2e2-4bb4-96e6-f1e895adef0c',
        "ZONE_ID": "999b7746-d2e2-4bb4-96e6-f1e895adef0c",
        "K8S_DEPLOY_PAYLOAD": {
            "appId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
            "name": "nginx-test",