Skip to content

Commit

Permalink
Bug Fix: SMB Source registration failure.
Browse files Browse the repository at this point in the history
Issue:
1) Registering SMB source fails if username contains @, format: user@domain
2) If user name is provided in following format: domain\username, source
   is registered but username is precede with slash.

Fix:
1) Add fix to support above formats and tested the same
  • Loading branch information
naveena-maplelabs committed Feb 16, 2024
1 parent 8cbee38 commit 5393b4b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ collections:
- python version >= '3.6'
- cohesity_management_sdk >= 1.6.0

To install the requirements, run **pip install -r [requirement.txt](https://github.com/cohesity/ansible-collection/blob/main/requirements.txt)**

## Table of contents

- [Getting Started](https://github.com/cohesity/ansible-collection/blob/main/README.md#get-started)
Expand Down
7 changes: 6 additions & 1 deletion plugins/modules/cohesity_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,10 +659,15 @@ def main():
prot_sources["nasMountCredentials"]["nasProtocol"] = "kNfs3"
elif module.params.get("nas_protocol") == "SMB":
prot_sources["nasMountCredentials"]["nasProtocol"] = "kCifs1"
if "\\" in ["nas_username"]:
nas_username = module.params.get("nas_username")
if "\\" in nas_username:
user_details = module.params.get("nas_username").split("\\")
prot_sources["nasMountCredentials"]["username"] = user_details[1]
prot_sources["nasMountCredentials"]["domain"] = user_details[0]
elif "@" in nas_username:
user_details = nas_username.split("@")
prot_sources["nasMountCredentials"]["domain"] = user_details[1]
prot_sources["nasMountCredentials"]["username"] = user_details[0]
else:
prot_sources["nasMountCredentials"]["username"] = module.params.get(
"nas_username"
Expand Down
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
cohesity-management-sdk
cohesity-management-sdk==1.10.1
pywinrm
requests==2.20
ansible==9.2.0

0 comments on commit 5393b4b

Please sign in to comment.