Commit 694a58b8 authored by Stavros-Anastasios Charismiadis's avatar Stavros-Anastasios Charismiadis
Browse files

Remove unnecessary logs

parent 72ce4e59
Loading
Loading
Loading
Loading
Loading
+0 −23
Original line number Diff line number Diff line
@@ -197,8 +197,6 @@ class PublishServiceOperations(Resource):
                    interconnected_ccf = interconnected_col.find_one({"dst_prov_dom": dom}) 
                    # 4. If yes, make a publish request with CCF certificate
                    if interconnected_ccf: 
                        current_app.logger.debug("CCF interconnected and API can be shared: {}".format(dom))

                        config_col = self.db.get_col_by_name(self.db.capif_configuration)
                        config = config_col.find_one({}, {"_id": 0})
                        ccf_id = config['ccf_id']
@@ -206,58 +204,38 @@ class PublishServiceOperations(Resource):

                        url = 'https://{}/published-apis/v1/{}/service-apis'.format(dom, ccf_id)

                        current_app.logger.debug("{}".format(url))

                        headers = {
                            'accept': 'application/json',
                            'Content-Type': 'application/json'
                        }

                        current_app.logger.debug("Add variables to request")

                        response = requests.request("POST", url, headers=headers, data=json.dumps(clean_n_camel_case(serviceapidescription_dict), cls=encoder.CustomJSONEncoder), cert=('certs/server.crt', 'certs/server.key'), verify='certs/ca.crt')

                        if (response.status_code == 201 or response.status_code == 200):
                            if rec.get("pub_api_path") is None:
                                current_app.logger.debug("pub_api_path not in keys")
                                rec.update({"pub_api_path": {"ccf_ids": [interconnected_ccf.get("ccf_id")]}})
                            else:
                                current_app.logger.debug("pub_api_path in keys")
                                ccf_list = rec.get("pub_api_path").get("ccf_ids")
                                current_app.logger.debug("fetch")
                                ccf_list.append(interconnected_ccf.get("ccf_id"))
                                current_app.logger.debug("append")
                                rec.update({"pub_api_path": {"ccf_ids": ccf_list}})
                                current_app.logger.debug("update")
                        else:
                            rec['shareable_info']['capif_prov_doms'].remove(dom)
                            if "CCF" in apf_id:
                                rec['pub_api_path']['ccf_ids'].remove(apf_id)

            current_app.logger.debug("Check pub_api_path")
            if "CCF" in apf_id:
                current_app.logger.debug("After CCF in apf_id")
                current_app.logger.debug("rec keys: {}".format(rec.keys()))
                if rec.get("pub_api_path") is None:
                    current_app.logger.debug("pub_api_path not in keys")
                    rec.update({"pub_api_path": {"ccf_ids": [apf_id]}})
                else:
                    current_app.logger.debug("pub_api_path in keys")
                    ccf_list = rec.get("pub_api_path").get("ccf_ids")
                    current_app.logger.debug("fetch")
                    ccf_list.append(apf_id)
                    current_app.logger.debug("append")
                    rec.update({"pub_api_path": {"ccf_ids": ccf_list}})
                    current_app.logger.debug("update")

            current_app.logger.debug("inserting record")
            mycol.insert_one(rec)

            if "APF" in apf_id:
                self.auth_manager.add_auth_service(api_id, apf_id)

            current_app.logger.debug("Service inserted in database")

            published_service = {
                key: value for key, value in rec.items()
                if key not in ("_id", "apf_id", "onboarding_date")
@@ -268,7 +246,6 @@ class PublishServiceOperations(Resource):
            res.headers['Location'] = f"https://{os.getenv('CAPIF_HOSTNAME')}/published-apis/v1/{str(apf_id)}/service-apis/{str(api_id)}"

            if res.status_code == 201:
                current_app.logger.info("Service published")
                event_to_send = self.service_api_availability_event(
                    clean_n_camel_case(
                        published_service))
+0 −10
Original line number Diff line number Diff line
@@ -39,12 +39,10 @@ class CapifDomainOperations(Resource):

    def add_capifdomain(self, capifdomaindetails):
        current_app.logger.debug("Interconnection: Add domain")
        current_app.logger.debug(capifdomaindetails)

        interconnected_col = self.db.get_col_by_name(self.db.interconnected)
        interconnected_ccf = interconnected_col.find_one({"dst_prov_dom": capifdomaindetails.dst_prov_dom})
        if interconnected_ccf:
            current_app.logger.debug("CAPIF domain already interconnected : {}".format(capifdomaindetails.dst_prov_dom))
            return make_response("CAPIF domain already interconnected", 409)

        url = "https://{}/helper/interconnection/establish".format(capifdomaindetails.dst_prov_dom)
@@ -77,7 +75,6 @@ class CapifDomainOperations(Resource):
                                        verify='certs/ca.crt')
        except requests.exceptions.RequestException as exc:
            detail = "Error calling interconnection endpoint: {}".format(str(exc))
            current_app.logger.error(detail)
            return internal_server_error(detail=detail, cause="REQUEST_FAILURE")

        try:
@@ -85,8 +82,6 @@ class CapifDomainOperations(Resource):
        except ValueError:
            inter_ccf = response.text

        current_app.logger.debug(inter_ccf)

        if response.status_code in (200, 201):
            if isinstance(inter_ccf, dict):
                interconnected_col.insert_one(inter_ccf)
@@ -104,20 +99,17 @@ class CapifDomainOperations(Resource):

    def remove_ccf_from_pub_api_path(self, services_col, ccf_id):
        """Drop a CCF from the publication path of every service API that references it."""
        current_app.logger.debug("Removing ccf_id {} from pub_api_path.ccf_ids".format(ccf_id))

        result = services_col.update_many(
            {"pub_api_path.ccf_ids": ccf_id},
            {"$pull": {"pub_api_path.ccf_ids": ccf_id}}
        )
        current_app.logger.debug("Service APIs updated: {}".format(result.modified_count))

        # ccf_ids must contain at least one entry, so null out pub_api_path once it is emptied
        cleaned = services_col.update_many(
            {"pub_api_path.ccf_ids": {"$size": 0}},
            {"$set": {"pub_api_path": None}}
        )
        current_app.logger.debug("Service APIs with empty pub_api_path nulled: {}".format(cleaned.modified_count))

        return result.modified_count

@@ -128,12 +120,10 @@ class CapifDomainOperations(Resource):
    def delete_capifdomain(self, ccf_id):
        """Remove an interconnection request for a CCF."""
        current_app.logger.debug("Interconnection: Delete domain")
        current_app.logger.debug(ccf_id)

        interconnected_col = self.db.get_col_by_name(self.db.interconnected)
        interconnected_ccf = interconnected_col.find_one({"ccf_id": ccf_id})
        if interconnected_ccf:
            current_app.logger.debug("CAPIF domain with ccf_id {} interconnected".format(ccf_id))
            # Retrieve the destination provider domain from the interconnected collection
            dst_prov_dom = interconnected_ccf.get("dst_prov_dom")
            # Retrieve the CAPIF configuration from the database to get the CCF ID of the originator CCF
+0 −7
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@ class CcfInstanceOperations(Resource):

    def add_ccfinstance(self, ccfinstancedetails):
        current_app.logger.debug("Interconnection: Add instance")
        current_app.logger.debug(ccfinstancedetails)

        with open('certs/ca.crt', 'rb') as ca_cert:
            server_ca = ca_cert.read()
@@ -68,36 +67,30 @@ class CcfInstanceOperations(Resource):
        ccfinstancedetails_dict['public_key'] = server_pub.decode("utf-8")
        ccfinstancedetails_dict['ccf_id'] = config['ccf_id']
        ccfinstancedetails_dict['dst_prov_dom'] = "{}:{}".format(os.getenv("CAPIF_HOSTNAME"), os.getenv("CAPIF_HTTPS_PORT"))
        current_app.logger.debug(ccfinstancedetails_dict)

        ccfinstancedetails_new = CcfInstanceDetails().from_dict(dict_to_camel_case(ccfinstancedetails_dict))
        current_app.logger.debug(ccfinstancedetails_new)
        res = make_response(object=serialize_clean(ccfinstancedetails_new), status=status)
        return res

    def remove_ccf_from_pub_api_path(self, services_col, ccf_id):
        """Drop a CCF from the publication path of every service API that references it."""
        current_app.logger.debug("Removing ccf_id {} from pub_api_path.ccf_ids".format(ccf_id))

        result = services_col.update_many(
            {"pub_api_path.ccf_ids": ccf_id},
            {"$pull": {"pub_api_path.ccf_ids": ccf_id}}
        )
        current_app.logger.debug("Service APIs updated: {}".format(result.modified_count))

        # ccf_ids must contain at least one entry, so null out pub_api_path once it is emptied
        cleaned = services_col.update_many(
            {"pub_api_path.ccf_ids": {"$size": 0}},
            {"$set": {"pub_api_path": None}}
        )
        current_app.logger.debug("Service APIs with empty pub_api_path nulled: {}".format(cleaned.modified_count))

        return result.modified_count

    def delete_ccfinstance(self, ccf_id):
        """Remove an established interconnection with a peer CCF."""
        current_app.logger.debug("Interconnection: Remove instance")
        current_app.logger.debug(ccf_id)

        interconnected_col = self.db.get_col_by_name(self.db.interconnected)
        interconnected_ccf = interconnected_col.find_one({"ccf_id": ccf_id})