Skip to content
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
18 changes: 16 additions & 2 deletions sos/policies/distros/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import os
import re

from sos import _sos as _
from sos.policies import Policy
from sos.policies.init_systems import InitSystem
from sos.policies.init_systems.systemd import SystemdInit
Expand Down Expand Up @@ -300,8 +301,21 @@ def pre_work(self):
if cmdline_opts.low_priority:
self._configure_low_priority()

if cmdline_opts.case_id:
self.case_id = cmdline_opts.case_id
# set or query for case id
self.case_id = self.prompt_for_case_id(cmdline_opts)

def prompt_for_case_id(self, cmdline_opts):
if not cmdline_opts.batch and not \
cmdline_opts.quiet:
if not cmdline_opts.case_id:
cmdline_opts.case_id = input(
_("Optionally, please enter the case id that you are "
"generating this report for: ")
)
self.case_id = cmdline_opts.case_id if \
cmdline_opts.case_id else ""

return self.case_id

def _configure_low_priority(self):
"""Used to constrain sos to a 'low priority' execution, potentially
Expand Down
3 changes: 3 additions & 0 deletions sos/upload/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ def execute(self):
if self.from_cmdline:
self.intro()
self.archive = self.opts.upload_file
self.caseid = self.policy.prompt_for_case_id(
cmdline_opts=self.opts
)
cmdline_target = self.opts.upload_target
if cmdline_target and cmdline_target != 'local':
self.upload_target = self.upload_targets[cmdline_target]
Expand Down
22 changes: 2 additions & 20 deletions sos/upload/targets/redhat.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,6 @@ def pre_work(self, hook_commons):

self.upload_directory = self.commons['cmdlineopts'].upload_directory

def prompt_for_case_id(self):
caseid = self.commons['cmdlineopts'].case_id if \
self.commons['cmdlineopts'].case_id else ""

# set or query for case id
if not self.commons['cmdlineopts'].batch and not \
self.commons['cmdlineopts'].quiet:
if caseid:
self.commons['cmdlineopts'].case_id = caseid
else:
self.commons['cmdlineopts'].case_id = input(
_("Optionally, please enter the case id that you are "
"generating this report for: ")
)
if self.commons['cmdlineopts'].case_id:
self.case_id = self.commons['cmdlineopts'].case_id

return self.case_id

def prompt_for_upload_user(self):
if self.commons['cmdlineopts'].upload_user:
self.ui_log.info(
Expand Down Expand Up @@ -101,7 +82,8 @@ def get_upload_url(self):
if self.commons['cmdlineopts'].upload_protocol == 'sftp':
return self.RH_SFTP_HOST
if not self.commons['cmdlineopts'].case_id and not\
self.prompt_for_case_id():
self.commons['policy'].prompt_for_case_id(
self.commons['cmdlineopts']):
return self.RH_SFTP_HOST

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am presuming this was removed on purpose and you don't need this if a case id is not there?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also not sure why this is being removed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, quite basic use case sos report -o host --batch --upload diverts: it tries to upload to the customer portal while it should use SFTP (no case id).

Instead of 3 lines removal, there must be a change on 2nd line to:

self.commons['policy'].prompt_for_case_id(self.commons['cmdlineopts']):

I had to overview this removal, sorry for ACKing it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason why I removed it was to run some tests and then I pushed the commit without re-adding it, sorry.
Thank you @arif-ali ++ for spotting this :)
I've just pushed a new commit with the code back


except Exception as e:
Expand Down
Loading