Skip to content
This repository has been archived by the owner on Nov 29, 2021. It is now read-only.

Fix get_status (backport #471) #472

Merged
merged 3 commits into from
Oct 21, 2021
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Removed
### Fixed
- Fix resume scan. [#464](https://github.com/greenbone/ospd/pull/464)

- Fix get_status. Backport #471.[#472](https://github.com/greenbone/ospd/pull/472)

[Unreleased]: https://github.com/greenbone/ospd/compare/v21.4.3...HEAD

Expand Down
4 changes: 3 additions & 1 deletion ospd/ospd.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,9 @@ def set_scan_status(self, scan_id: str, status: ScanStatus) -> None:
def get_scan_status(self, scan_id: str) -> ScanStatus:
"""Get scan_id scans's status."""
status = self.scan_collection.get_status(scan_id)
logger.debug('%s: Current scan status: %s,', scan_id, status.name)
st = status.name if status else None
logger.debug('%s: Current scan status: %s,', scan_id, st)

return status

def scan_exists(self, scan_id: str) -> bool:
Expand Down
17 changes: 16 additions & 1 deletion ospd/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,13 @@ def set_status(self, scan_id: str, status: ScanStatus) -> None:

def get_status(self, scan_id: str) -> ScanStatus:
"""Get scan_id scans's status."""
status = None
try:
status = self.scans_table[scan_id].get('status')
except KeyError:
logger.error("Scan ID %s not found", scan_id)

return self.scans_table[scan_id].get('status')
return status

def get_options(self, scan_id: str) -> Dict:
"""Get scan_id scan's options list."""
Expand Down Expand Up @@ -425,10 +430,20 @@ def simplify_exclude_host_count(self, scan_id: str) -> int:
Count of excluded host.
"""
exc_hosts_list = target_str_to_list(self.get_exclude_hosts(scan_id))
logger.debug(
'%s: Excluded Hosts: %s',
scan_id,
pformat(exc_hosts_list),
)

finished_hosts_list = target_str_to_list(
self.get_finished_hosts(scan_id)
)
logger.debug(
'%s: Finished Hosts: %s',
scan_id,
pformat(finished_hosts_list),
)

# Remove finished hosts from excluded host list
if finished_hosts_list and exc_hosts_list:
Expand Down