Skip to content

Commit

Permalink
feat: modify debug code
Browse files Browse the repository at this point in the history
  • Loading branch information
ImMin5 committed Mar 7, 2024
1 parent 47d6931 commit 301e09c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
16 changes: 15 additions & 1 deletion src/cloudforet/search/conf/search_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
},
"identity.Project": {
"request": {"search": ["name", "project_id"]},
"request": {"search": ["name"]},
"response": {"resource_id": "project_id", "name": "{name}"},
},
"identity.Workspace": {
Expand All @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion src/cloudforet/search/lib/pymongo_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from spaceone.core import config
from pymongo import MongoClient

_LOGGER = logging.getLogger(__name__)
_LOGGER = logging.getLogger("spaceone")


class SpaceONEPymongoClient:
Expand Down
2 changes: 1 addition & 1 deletion src/cloudforet/search/manager/identity_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
18 changes: 9 additions & 9 deletions src/cloudforet/search/manager/resource_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from cloudforet.search.lib.pymongo_client import SpaceONEPymongoClient

_LOGGER = logging.getLogger(__name__)
_LOGGER = logging.getLogger("spaceone")


class ResourceManager(BaseManager):
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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]:
Expand Down
5 changes: 3 additions & 2 deletions src/cloudforet/search/service/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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():
Expand All @@ -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
Expand Down

0 comments on commit 301e09c

Please sign in to comment.