Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get user_details from perf ldap service #896

Merged
merged 1 commit into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading