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

DR-766 fix auto add; DR-759 fix remove job messaging #1312

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
2 changes: 1 addition & 1 deletion keepercommander/commands/discover/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def from_configuration_uid(params: KeeperParams, configuration_uid: str):
None)

if gateway is None:
print(f'{bcolors.FAIL}Gateway [{gateway_uid}] was not found.{bcolors.ENDC}')
# print(f'{bcolors.FAIL}Gateway [{gateway_uid}] was not found.{bcolors.ENDC}')
return

application_id = utils.base64_url_encode(gateway.applicationUid)
Expand Down
14 changes: 9 additions & 5 deletions keepercommander/commands/discover/job_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class PAMGatewayActionDiscoverJobStartCommand(PAMGatewayActionDiscoverCommandBas
action='store_true', help='Skip discovering cloud users.')
parser.add_argument('--cred', required=False, dest='credentials',
action='append', help='List resource credentials.')
parser.add_argument('--cred_file', required=False, dest='credential_file',
action='store', help='A file containing ')
parser.add_argument('--cred-file', required=False, dest='credential_file',
action='store', help='A JSON file containing list of credentials.')

def get_parser(self):
return PAMGatewayActionDiscoverJobStartCommand.parser
Expand Down Expand Up @@ -105,6 +105,7 @@ def execute(self, params, **kwargs):

jobs = Jobs(record=gateway_context.configuration, params=params)
current_job_item = jobs.current_job
removed_prior_job = None
if current_job_item is not None:
if current_job_item.is_running is True:
print("")
Expand All @@ -122,10 +123,11 @@ def execute(self, params, **kwargs):
status.execute(params=params)
print("")

yn = input("Do you wish to remove the active discovery job and run a new one [Y/N]>").lower()
yn = input("Do you wish to remove the active discovery job and run a new one [Y/N]> ").lower()
while True:
if yn[0] == "y":
jobs.cancel(current_job_item.job_id)
removed_prior_job = current_job_item.job_id
break
elif yn[0] == "n":
print(f"{bcolors.FAIL}Not starting a discovery job.{bcolors.ENDC}")
Expand Down Expand Up @@ -221,8 +223,10 @@ def execute(self, params, **kwargs):

if "has been queued" in data.get("Response", ""):

print("")
print("The discovery job is currently running.")
if removed_prior_job is None:
print("The discovery job is currently running.")
else:
print(f"Active discovery job {removed_prior_job} has been removed and new discovery job is running.")
print(f"To check the status, use the command '{bcolors.OKGREEN}pam action discover status{bcolors.ENDC}'.")
print(f"To stop and remove the current job, use the command "
f"'{bcolors.OKGREEN}pam action discover remove -j <Job ID>'.")
Expand Down
12 changes: 12 additions & 0 deletions keepercommander/commands/discover/result_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,15 @@ def _prompt_admin(self, parent_vertex: DAGVertex, content: DiscoveryObject, acl:
)
print("")

@staticmethod
def _display_auto_add_results(bulk_add_records: List[BulkRecordAdd]):

add_count = len(bulk_add_records)
if add_count > 0:
print("")
print(f"{bcolors.OKGREEN}From the rules, automatically queued {add_count} "
f"record{'' if add_count == 1 else 's'} to be added.{bcolors.ENDC}")

@staticmethod
def _prompt_confirm_add(bulk_add_records: List[BulkRecordAdd]):

Expand Down Expand Up @@ -1265,6 +1274,9 @@ def execute(self, params: KeeperParams, **kwargs):
# A function to get directory users
directory_info_func=self._get_directory_info,

# Pass method that will display auto added records.
auto_add_result_func=self._display_auto_add_results,

# Provides a cache of the record key to record UID.
record_cache=record_cache,

Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ pydantic>=2.6.4
# pip uninstall discovery-common -y
# python3 setup.py wheel --whlsrc ~/src/discovery-common --libdir $PWD/libs --reqfiles $PWD/requirements.txt
# pip install $(ls libs/discovery_common-*)
./libs/discovery_common-1.0.17-py3-none-any.whl
./libs/discovery_common-1.0.18-py3-none-any.whl
Loading