diff --git a/src/cloudforet/search/conf/search_conf.py b/src/cloudforet/search/conf/search_conf.py index 4a18fa4..822f537 100644 --- a/src/cloudforet/search/conf/search_conf.py +++ b/src/cloudforet/search/conf/search_conf.py @@ -7,7 +7,7 @@ }, }, "identity.Project": { - "request": {"search": ["name", "project_id"]}, + "request": {"search": ["name"]}, "response": {"resource_id": "project_id", "name": "{name}"}, }, "identity.Workspace": { @@ -21,6 +21,20 @@ "name": "{group} > {name}", }, }, + "inventory.CloudService": { + "request": { + "search": [ + "name", + "ip_addresses", + "account", + ], + "filter": [{"state": "ACTIVE"}], + }, + "response": { + "resource_id": "cloud_service_id", + "name": "{name}", + }, + }, "dashboard.PublicDashboard": { "request": {"search": ["name"]}, "response": { diff --git a/src/cloudforet/search/lib/pymongo_client.py b/src/cloudforet/search/lib/pymongo_client.py index 99d2de0..917053c 100644 --- a/src/cloudforet/search/lib/pymongo_client.py +++ b/src/cloudforet/search/lib/pymongo_client.py @@ -3,7 +3,7 @@ from spaceone.core import config from pymongo import MongoClient -_LOGGER = logging.getLogger(__name__) +_LOGGER = logging.getLogger("spaceone") class SpaceONEPymongoClient: diff --git a/src/cloudforet/search/manager/identity_manager.py b/src/cloudforet/search/manager/identity_manager.py index 8b44e49..8950c10 100644 --- a/src/cloudforet/search/manager/identity_manager.py +++ b/src/cloudforet/search/manager/identity_manager.py @@ -6,7 +6,7 @@ from spaceone.core.connector.space_connector import SpaceConnector from spaceone.core.auth.jwt.jwt_util import JWTUtil -_LOGGER = logging.getLogger(__name__) +_LOGGER = logging.getLogger("spaceone") class IdentityManager(BaseManager): diff --git a/src/cloudforet/search/manager/resource_manager.py b/src/cloudforet/search/manager/resource_manager.py index 8998e92..96bff7a 100644 --- a/src/cloudforet/search/manager/resource_manager.py +++ b/src/cloudforet/search/manager/resource_manager.py @@ -7,7 +7,7 @@ from cloudforet.search.lib.pymongo_client import SpaceONEPymongoClient -_LOGGER = logging.getLogger(__name__) +_LOGGER = logging.getLogger("spaceone") class ResourceManager(BaseManager): @@ -58,10 +58,6 @@ def search_resource( result["description"] = dashboard_type _LOGGER.debug(f"[search] find_filter: {find_filter}") - print( - f"[search] find_filter: {find_filter}" - ) # todo: need to remove temporary debug code - return results def list_public_project(self, domain_id: str, workspace_id: str) -> list: @@ -155,7 +151,9 @@ def get_workspace_owner_and_member_workspaces( ) -> Tuple: workspace_member_workspaces = [] workspace_owner_workspaces = [] - db_name, collection_name = self._get_collection_and_db_name("identity.UserRole") + db_name, collection_name = self._get_collection_and_db_name( + "identity.RoleBinding" + ) find_filter = {"domain_id": domain_id, "user_id": user_id} if workspace_ids: @@ -165,10 +163,12 @@ def get_workspace_owner_and_member_workspaces( for result in results: if result["role_type"] == "WORKSPACE_OWNER": - workspace_member_workspaces.append(result["workspace_id"]) - elif result["role_type"] == "WORKSPACE_MEMBER": workspace_owner_workspaces.append(result["workspace_id"]) - + elif result["role_type"] == "WORKSPACE_MEMBER": + workspace_member_workspaces.append(result["workspace_id"]) + _LOGGER.debug( + f"[get_workspace_owner_and_member_workspaces] workspace_owner_workspaces: {workspace_owner_workspaces}, workspace_member_workspaces: {workspace_member_workspaces}" + ) return workspace_owner_workspaces, workspace_member_workspaces def _get_collection_and_db_name(self, resource_type: str) -> Tuple[str, str]: diff --git a/src/cloudforet/search/service/resource.py b/src/cloudforet/search/service/resource.py index 5a09c91..5d65253 100644 --- a/src/cloudforet/search/service/resource.py +++ b/src/cloudforet/search/service/resource.py @@ -12,7 +12,7 @@ from cloudforet.search.model.resource.response import * from cloudforet.search.model.resource.request import * -_LOGGER = logging.getLogger(__name__) +_LOGGER = logging.getLogger("spaceone") @authentication_handler @@ -225,7 +225,7 @@ def _make_filter_by_workspaces( or_filter = {"$or": []} if workspace_owner_workspaces: find_filter["$and"].append( - {"$or": {"workspace_id": {"$in": workspace_owner_workspaces}}} + {"$or": [{"workspace_id": {"$in": workspace_owner_workspaces}}]} ) for workspace_id, user_projects in workspace_member_project_map.items(): @@ -236,6 +236,7 @@ def _make_filter_by_workspaces( } ) find_filter["$and"].append(or_filter) + _LOGGER.debug(f"[_make_filter_by_workspaces] find_filter: {find_filter}") return find_filter @staticmethod