Skip to content

Commit

Permalink
get user_details from perf ldap service (#896)
Browse files Browse the repository at this point in the history
/LGTM
  • Loading branch information
athiruma authored Feb 19, 2025
1 parent c1b50ca commit c859a0a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cloud_governance/common/ldap/ldap_search.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import os

import ldap
# installation for rhel/centos - python3.9
# sudo dnf install -y python39-devel openldap-devel gcc

from cloud_governance.common.logger.init_logger import logger
from cloud_governance.common.utils.api_requests import APIRequests


class LdapSearch:

def __init__(self, ldap_host_name: str):
self.__ldap_client = ldap.initialize(f'ldap://{ldap_host_name}')
self.__perf_services_url = os.environ.get('PERF_SERVICES_URL')

def __get_manager_name(self, manager_data: str):
"""
Expand Down Expand Up @@ -62,9 +66,14 @@ def __get_details(self, user_name: str):

def get_user_details(self, user_name):
"""
This method return the ldap results and organize data
This method returns the ldap results and organizes data
@param user_name:
@return:
"""
if self.__perf_services_url:
api_request = APIRequests()
api_url = self.__perf_services_url + f"/ldap/{user_name}"
response = api_request.get(api_url)
return response
user_data = self.__get_details(user_name=user_name)
return self.__organise_user_details(data=user_data)
2 changes: 2 additions & 0 deletions cloud_governance/main/environment_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ def __init__(self):
self._environment_variables_dict['CLOUDABILITY_DIMENSIONS'] = EnvironmentVariables.get_env(
'CLOUDABILITY_DIMENSIONS', 'date,category4,vendor_account_name,vendor_account_identifier,vendor')

self._environment_variables_dict['PERF_SERVICES_URL'] = EnvironmentVariables.get_env('PERF_SERVICES_URL', '')

@staticmethod
def to_bool(arg, def_val: bool = None):
if isinstance(arg, bool):
Expand Down

0 comments on commit c859a0a

Please sign in to comment.