aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--man/en/sos-report.17
-rw-r--r--sos/collector/__init__.py4
-rw-r--r--sos/policies/distros/__init__.py28
-rw-r--r--sos/policies/distros/redhat.py1
-rw-r--r--sos/policies/distros/ubuntu.py2
-rw-r--r--sos/report/__init__.py4
6 files changed, 29 insertions, 17 deletions
diff --git a/man/en/sos-report.1 b/man/en/sos-report.1
index a6d247b4..1e626e09 100644
--- a/man/en/sos-report.1
+++ b/man/en/sos-report.1
@@ -362,6 +362,13 @@ be used provided all other required values (case number, upload user) are provid
Specify a directory to upload to, if one is not specified by a vendor default location
or if your destination server does not allow writes to '/'.
.TP
+.B \--upload-method METHOD
+Specify the HTTP method to use for uploading to the provided --upload-url. Valid
+values are 'auto' (default), 'put', or 'post'. The use of 'auto' will default to
+the method required by the policy-default upload location, if one exists.
+
+This option has no effect on upload methods other than HTTPS.
+.TP
.B \--experimental
Enable plugins marked as experimental. Experimental plugins may not have
been tested for this port or may still be under active development.
diff --git a/sos/collector/__init__.py b/sos/collector/__init__.py
index 5c1b2ee8..e9f06c35 100644
--- a/sos/collector/__init__.py
+++ b/sos/collector/__init__.py
@@ -101,6 +101,7 @@ class SoSCollector(SoSComponent):
'upload_directory': None,
'upload_user': None,
'upload_pass': None,
+ 'upload_method': 'auto'
}
def __init__(self, parser, parsed_args, cmdline_args):
@@ -364,6 +365,9 @@ class SoSCollector(SoSComponent):
help="Username to authenticate with")
collect_grp.add_argument("--upload-pass", default=None,
help="Password to authenticate with")
+ collect_grp.add_argument("--upload-method", default='auto',
+ choices=['auto', 'put', 'post'],
+ help="HTTP method to use for uploading")
# Group the cleaner options together
cleaner_grp = parser.add_argument_group(
diff --git a/sos/policies/distros/__init__.py b/sos/policies/distros/__init__.py
index 0a77dbbc..b9a4d0d8 100644
--- a/sos/policies/distros/__init__.py
+++ b/sos/policies/distros/__init__.py
@@ -48,7 +48,7 @@ class LinuxPolicy(Policy):
_upload_directory = '/'
_upload_user = None
_upload_password = None
- _use_https_streaming = False
+ _upload_method = None
default_container_runtime = 'docker'
_preferred_hash_name = None
upload_url = None
@@ -253,8 +253,6 @@ class LinuxPolicy(Policy):
protocol header
:_upload_user: Default username, if any else None
:_upload_password: Default password, if any else None
- :_use_https_streaming: Set to True if the HTTPS endpoint supports
- streaming data
The following Class Attrs may optionally be overidden by the Policy
@@ -375,9 +373,8 @@ class LinuxPolicy(Policy):
"""
raise NotImplementedError("SFTP support is not yet implemented")
- def _upload_https_streaming(self, archive):
- """If upload_https() needs to use requests.put(), this method is used
- to provide streaming functionality
+ def _upload_https_put(self, archive):
+ """If upload_https() needs to use requests.put(), use this method.
Policies should override this method instead of the base upload_https()
@@ -391,9 +388,8 @@ class LinuxPolicy(Policy):
"""
return {}
- def _upload_https_no_stream(self, archive):
- """If upload_https() needs to use requests.post(), this method is used
- to provide non-streaming functionality
+ def _upload_https_post(self, archive):
+ """If upload_https() needs to use requests.post(), use this method.
Policies should override this method instead of the base upload_https()
@@ -409,10 +405,6 @@ class LinuxPolicy(Policy):
def upload_https(self):
"""Attempts to upload the archive to an HTTPS location.
- Policies may define whether this upload attempt should use streaming
- or non-streaming data by setting the `use_https_streaming` class
- attr to True
-
:returns: ``True`` if upload is successful
:rtype: ``bool``
@@ -423,10 +415,14 @@ class LinuxPolicy(Policy):
"library")
with open(self.upload_archive_name, 'rb') as arc:
- if not self._use_https_streaming:
- r = self._upload_https_no_stream(arc)
+ if self.commons['cmdlineopts'].upload_method == 'auto':
+ method = self._upload_method
+ else:
+ method = self.commons['cmdlineopts'].upload_method
+ if method == 'put':
+ r = self._upload_https_put(arc)
else:
- r = self._upload_https_streaming(arc)
+ r = self._upload_https_post(arc)
if r.status_code != 201:
if r.status_code == 401:
raise Exception(
diff --git a/sos/policies/distros/redhat.py b/sos/policies/distros/redhat.py
index 8b7b7eb3..f3751991 100644
--- a/sos/policies/distros/redhat.py
+++ b/sos/policies/distros/redhat.py
@@ -214,6 +214,7 @@ support representative.
_upload_url = RH_FTP_HOST
_upload_user = 'anonymous'
_upload_directory = '/incoming'
+ _upload_method = 'post'
def __init__(self, sysroot=None, init=None, probe_runtime=True,
remote_exec=None):
diff --git a/sos/policies/distros/ubuntu.py b/sos/policies/distros/ubuntu.py
index 308c1e35..cf9dfd69 100644
--- a/sos/policies/distros/ubuntu.py
+++ b/sos/policies/distros/ubuntu.py
@@ -24,7 +24,7 @@ class UbuntuPolicy(DebianPolicy):
_upload_url = "https://files.support.canonical.com/uploads/"
_upload_user = "ubuntu"
_upload_password = "ubuntu"
- _use_https_streaming = True
+ _upload_method = 'put'
def __init__(self, sysroot=None, init=None, probe_runtime=True,
remote_exec=None):
diff --git a/sos/report/__init__.py b/sos/report/__init__.py
index 93fba939..64e414a6 100644
--- a/sos/report/__init__.py
+++ b/sos/report/__init__.py
@@ -118,6 +118,7 @@ class SoSReport(SoSComponent):
'upload_directory': None,
'upload_user': None,
'upload_pass': None,
+ 'upload_method': 'auto',
'add_preset': '',
'del_preset': ''
}
@@ -299,6 +300,9 @@ class SoSReport(SoSComponent):
help="Username to authenticate to server with")
report_grp.add_argument("--upload-pass", default=None,
help="Password to authenticate to server with")
+ report_grp.add_argument("--upload-method", default='auto',
+ choices=['auto', 'put', 'post'],
+ help="HTTP method to use for uploading")
# Group to make add/del preset exclusive
preset_grp = report_grp.add_mutually_exclusive_group()