diff options
author | Pavel Moravec <pmoravec@redhat.com> | 2020-10-15 13:45:37 +0200 |
---|---|---|
committer | Jake Hunsaker <jhunsake@redhat.com> | 2020-10-19 10:23:41 -0400 |
commit | 21720a0f8c9cf6739e26470b2280e005f0f3e3f1 (patch) | |
tree | 9d47f171f6c6b7533db367e7406ce4633b7cee4a | |
parent | 613f507a43a1cfff6c6d0e242c122b4b2b55e1dc (diff) | |
download | sos-21720a0f8c9cf6739e26470b2280e005f0f3e3f1.tar.gz |
[policy] Use FTP server when user isnt set in batch mode
Caling "sos report --upload --case-id=123 --batch" should fallback
to uploading to FTP server as the upload user is unknown and can't
be prompted in batch mode.
Resolves: #2276
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r-- | sos/policies/redhat.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/sos/policies/redhat.py b/sos/policies/redhat.py index d079406f..3a65b9fa 100644 --- a/sos/policies/redhat.py +++ b/sos/policies/redhat.py @@ -324,13 +324,21 @@ support representative. self.upload_url = RH_FTP_HOST self.upload_user = self._upload_user + def _upload_user_set(self): + user = self.get_upload_user() + return user and (user != 'anonymous') + def get_upload_url(self): if self.upload_url: return self.upload_url if self.commons['cmdlineopts'].upload_url: return self.commons['cmdlineopts'].upload_url - if not self.case_id: - # Cannot use the RHCP. Use anonymous dropbox + # anonymous FTP server should be used as fallback when either: + # - case id is not set, or + # - upload user isn't set AND batch mode prevents to prompt for it + if (not self.case_id) or \ + ((not self._upload_user_set()) and + self.commons['cmdlineopts'].batch): self.upload_user = self._upload_user if self.upload_directory is None: self.upload_directory = self._upload_directory |