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

Feature: ADS Enhancements #114

Merged
merged 16 commits into from
Sep 19, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
ADS module enhancements
  • Loading branch information
Bhavneet-Sharma committed Sep 16, 2024

Verified

This commit was signed with the committer’s verified signature.
commit 283a0aea3174c813c0c4f3a31ab7ad00964de84b
15 changes: 7 additions & 8 deletions plugins/modules/ads.py
Original file line number Diff line number Diff line change
@@ -797,8 +797,8 @@ def get_ads_details(self, ads_name):
ads_api_response = []
for name in ads_name:
api_response = self.auth_api_instance.get_providers_ads_by_id(
name)
ads_api_response.append(api_response.ads[0].to_dict())
name).to_dict()
ads_api_response.append(api_response['ads'][0])

return ads_api_response
except utils.ApiException as e:
@@ -860,7 +860,7 @@ def create_ads(self, domain, instance, ads_user, ads_password, ads_parameters):
self.ads_name.insert(0, api_response.id)
create_flag = True
except utils.ApiException as e:
error_message = "Add an Active Directory provider failed with" + \
error_message = "Add an Active Directory provider failed with " + \
utils.determine_error(error_obj=e)
LOG.error(error_message)
self.module.fail_json(msg=error_message)
@@ -890,7 +890,7 @@ def update_ads(self, ads_name, modified_ads, ads_details):
LOG.info(message)
modify_flag = True
except utils.ApiException as e:
error_message = "Modifying ADS provider failed with" + \
error_message = "Modifying Active Directory provider failed with " + \
utils.determine_error(error_obj=e)
LOG.error(error_message)
self.module.fail_json(msg=error_message)
@@ -915,7 +915,7 @@ def delete_ads(self, ads_name, ads_details):
LOG.info(message)
delete_flag = True
except utils.ApiException as e:
error_message = "Deleting ADS provider failed with" + \
error_message = "Deleting ADS provider failed with " + \
utils.determine_error(error_obj=e)
LOG.error(error_message)
self.module.fail_json(msg=error_message)
@@ -1020,7 +1020,6 @@ def get_modified_ads(self, input_ads, array_ads):
updated_input_ads = self.remove_none(ads_key=ads_keys, input_ad_param=input_ads)

for key in list(updated_input_ads):

if updated_input_ads.get(key) != array_ads[0][key]:

updated_ads_dict[key] = updated_input_ads[key]
@@ -1052,7 +1051,7 @@ def get_auth_providers_summary(self):

return providers_summary
except utils.ApiException as e:
error_message = "Get auth providers summary failed with" + \
error_message = "Get auth providers summary failed with " + \
utils.determine_error(error_obj=e)
LOG.error(error_message)
self.module.fail_json(msg=error_message)
@@ -1078,7 +1077,7 @@ def update_ads_access_zone_info(self, ads_name, ads_details):

except utils.ApiException as e:
error_message = "Update ADS with access zone details " \
"failed with" + utils.determine_error(error_obj=e)
"failed with " + utils.determine_error(error_obj=e)
LOG.error(error_message)
self.module.fail_json(msg=error_message)

148 changes: 148 additions & 0 deletions tests/unit/plugins/module_utils/mock_ads_api.py
Original file line number Diff line number Diff line change
@@ -9,6 +9,154 @@

__metaclass__ = type

ADS_NAME = 'ads.domain.com'
DOMAIN_NAME = 'SAMPLE.LAB.EMC.COM'

ADS_COMMAN_ARG = {
'domain_name': None,
'instance_name': None,
'ads_user': None,
'ads_password': None,
'state': 'present',
'ads_parameters': {
'groupnet': None,
'home_directory_template': None,
'login_shell': None,
'machine_account': None,
'organizational_unit': None,
'allocate_gids': None,
'allocate_uids': None,
'assume_default_domain': None,
'authentication': None,
'check_online_interval': None,
'controller_time': None,
'create_home_directory': None,
'domain_offline_alerts': None,
'ignore_all_trusts': None,
'ignored_trusted_domains': None,
'include_trusted_domains': None,
'ldap_sign_and_seal': None,
'lookup_groups': None,
'lookup_normalize_groups': None,
'lookup_normalize_users': None,
'lookup_users': None,
'machine_password_changes': None,
'nss_enumeration': None,
'restrict_findable': None,
'store_sfu_mappings': None,
'machine_password_lifespan': None,
'rpc_call_timeout': None,
'server_retry_limit': None,
'sfu_support': None,
'extra_expected_spns': None,
'findable_groups': None,
'findable_users': None,
'lookup_domains': None,
'unfindable_groups': None,
'unfindable_users': None,
},
'spns': None,
'spn_command': None
}

ADS_DETAILS = {
"ads": [
{
"allocate_gids": True,
"allocate_uids": True,
"assume_default_domain": False,
"authentication": True,
"check_online_interval": 300,
"controller_time": 1726470128,
"create_home_directory": True,
"domain_offlin,e_alerts": False,
"extra_expected_spns": [],
"findable_groups": [],
"findable_users": [],
"forest": DOMAIN_NAME,
"groupnet": "groupnet0",
"home_directory_template": "/ifs/home/%D/%D",
"hostname": "sample-isilon-x.sample.lab.emc.com",
"id": DOMAIN_NAME,
"ignore_all_trusts": False,
"ignored_trusted_domains": [],
"include_trusted_domains": [
"SAMPLE.LAB.EMC.COM"
],
"ldap_sign_and_seal": False,
"login_shell": "/bin/zsh",
"lookup_domains": [],
"lookup_groups": True,
"lookup_normalize_groups": True,
"lookup_normalize_users": True,
"lookup_users": True,
"machine_account": "SAMPLE-ISILON-X$",
"machine_password_changes": True,
"machine_password_lifespan": 2592000,
"name": DOMAIN_NAME,
"netbios_domain": "SAMMPLERTP",
"nss_enumeration": False,
"primary_domain": DOMAIN_NAME,
"recommended_spns": [
"HOST/sample-isilon-x",
"nfs/sample-isilon-x",
],
"restrict_findable": False,
"rpc_call_timeout": 400,
"server_retry_limit": 6,
"sfu_support": "none",
"site": "Default-First-Site-Name",
"spns": [
"HOST/sample-isilon-x",
"nfs/sample-isilon-x",
],
"status": "online",
"store_sfu_mappings": False,
"system": False,
"unfindable_groups": [],
"unfindable_users": [],
"zone_name": "System"
}
]
}

CREATE_ARGS = {
'domain_name': ADS_NAME,
'instance_name': ADS_NAME,
'ads_user': 'ads_user',
'ads_password': 'ads_password',
'state': 'present',
'ads_parameters': {
'groupnet': 'groupnet',
'home_directory_template': '/home',
'login_shell': '/bin/zsh',
'machine_account': 'test_account',
'organizational_unit': 'OU',
'allocate_gids': True,
'allocate_uids': False,
'assume_default_domain': True,
'authentication': True,
}
}

MODIFY_ARGS = {
'domain_name': ADS_NAME,
'ads_user': 'ads_user',
'ads_password': 'ads_password',
'state': 'present',
'ads_parameters': {
'allocate_gids': True,
'allocate_uids': False,
'assume_default_domain': True,
'authentication': True
},
'spns':
[{'spn': 'abc', 'state': 'present'},
{'spn': 'def', 'state': 'present'},
{'spn': 'HOST/sample-isilon-x', 'state': 'absent'}],
'spn_command': 'fix'
}


def get_ads_response():
ads_response = MagicMock()
Loading