Skip to content

Commit

Permalink
Anfield Bug Fix
Browse files Browse the repository at this point in the history
Issue:
1) AD users and groups are not imported to the new cluster.

Fix:
1) While exporting AD objects were ignored, Resolved the issue
and all the AD users and group are exported.
  • Loading branch information
naveena-maplelabs committed Jul 19, 2023
1 parent 002989e commit 4a97bda
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 3 additions & 1 deletion samples/project-anfield/export_cluster_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@
# Export Active directory entries and AD users and groups along with roles.
if export_access_mgmnt:
cluster_dict["ad"] = library.get_ad_entries(cohesity_client)
cluster_dict["ad_objects"] = library.get_ad_objects(cohesity_client)
domains = [ad.domain_name for ad in cluster_dict["ad"]]
cluster_dict["ad_objects"] = library.get_ad_objects(
cohesity_client, domains)
cluster_dict["roles"] = cohesity_client.roles.get_roles()

exported_res = library.debug()
Expand Down
16 changes: 15 additions & 1 deletion samples/project-anfield/import_cluster_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1835,10 +1835,20 @@ def add_active_directory():
domain_name = domain.domain_name
if not configparser.has_section(domain_name):
ERROR_LIST.append(
"Please update credentials for active directory '%s'" % domain_name
"Please provide credentials for active directory '%s'" % domain_name
)
continue
if domain_name not in existing_ad_list:
if not configparser[domain_name].get("username"):
ERROR_LIST.append(
"Please provide username for active directory '%s'" % domain_name
)
continue
if not configparser[domain_name].get("password"):
ERROR_LIST.append(
"Please provide password for active directory '%s'" % domain_name
)
continue
domain.user_name = configparser[domain_name]["username"]
domain.password = configparser[domain_name]["password"]
if configparser[domain_name].get("machine_accounts", None):
Expand All @@ -1853,6 +1863,8 @@ def add_active_directory():
"Error while adding active directory '%s', err msg %s"
% (domain_name, err)
)
# Sleep for 10 seconds.
time.sleep(10)


def create_roles():
Expand Down Expand Up @@ -1927,6 +1939,7 @@ def create_ad_objects():
try:
if user.username not in existing_users:
cohesity_client.principals.create_user(user)
imported_res_dict["AD Users"].append(user.username)
except APIException as err:
ERROR_LIST.append(
"Error while creating AD user '%s', err msg %s"
Expand All @@ -1936,6 +1949,7 @@ def create_ad_objects():
try:
if group.name not in existing_groups:
cohesity_client.groups.create_group(group)
imported_res_dict["AD Groups"].append(group.name)
except APIException as err:
ERROR_LIST.append(
"Error while creating AD group '%s', err msg %s" % (group.name, err)
Expand Down

0 comments on commit 4a97bda

Please sign in to comment.