Skip to content

Commit

Permalink
Remove --upload option
Browse files Browse the repository at this point in the history
The --upload option has a lot of limitations and has not been
widely used. Recent trends are to handle uploading data in
higher-level tools (e.g. redhat-support-tool or web based
management UIs) and the python ftp library does not support
modern requirements like HTTP proxy traversal or encryption.

Fixes Issue #217

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
  • Loading branch information
bmr-cymru committed Jan 24, 2014
1 parent 55b48fa commit d523cfb
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 118 deletions.
41 changes: 23 additions & 18 deletions man/en/sos.conf.5
Expand Up @@ -6,26 +6,31 @@ sos.conf \- sosreport configuration
sosreport uses a configuration file at /etc/sos.conf.
.SH PARAMETERS
.sp
There are 3 sections of configuration in the sosreport configuration file: general,
plugins, and tunables.
.SH [general] OPTIONS
.sp
.in
ftp_upload_url Default ftp server to send reports.
.in
gpg_keyring Default gpgkey.
.in
gpg_recipient GPG recipient
.in
smtp_server Mail server
.SH [plugins] OPTIONS
.sp
.in
There are two sections in the sosreport configuration file:
plugins, and tunables. Options are set using 'ini'-style
\fBname = value\fP pairs.

Some options accept a comma separated list of values.

.TP
\fB[plugins]\fP
disable Comma separated list of plugins to disable.
.SH [tunables] OPTIONS
.TP
\fB[tunables]\fP
plugin.option Alter available options for defined plugin.
.SH EXAMPLES
To disable the 'general' and 'filesys' plugins:
.LP
[plugins]
.br
disable = general, filesys
.sp
.in
(plugin, option) Alter available options for defined plugin.
To disable rpm package verification in the RPM plugin:
.LP
[tunables]
.br
rpm.rpmva = off
.br
.SH FILES
.sp
/etc/sos.conf
Expand Down
5 changes: 1 addition & 4 deletions man/en/sosreport.1
Expand Up @@ -10,7 +10,7 @@ sosreport \- Collect and package diagnostic and support data
[-a|--alloptions] [-v|--verbose]\fR
[--report] [--config-file conf] [--batch]\fR
[--build] [--name name] [--ticket-number number]
[--debug] [--upload] [--tmp-dir directory]\fR
[--debug] [--tmp-dir directory]\fR
[--profile] [--help]\fR
.SH DESCRIPTION
\fBsosreport\fR generates a compressed tar archive of diagnostic
Expand Down Expand Up @@ -50,9 +50,6 @@ specified value in the plug-in PLUGNAME.
.B \-a, \--alloptions
Set all boolean options to True for all enabled plug-ins.
.TP
.B \--upload FTP_SERVER
Upload the report to the configured destination.
.TP
.B \-v, \--verbose
Increase logging verbosity. May be specified multiple times to enable
additional debugging messages.
Expand Down
73 changes: 0 additions & 73 deletions sos/policies/__init__.py
Expand Up @@ -282,79 +282,6 @@ def display_results(self, final_filename=None, build=False):
self._print(_("Please send this file to your support representative."))
self._print()

def upload_results(self, final_filename):

# make sure a report exists
if not final_filename:
return False

self._print()
# make sure it's readable
try:
fp = open(final_filename, "r")
except:
return False

# read ftp URL from configuration
if self.commons['cmdlineopts'].upload:
upload_url = self.commons['cmdlineopts'].upload
else:
try:
upload_url = self.commons['config'].get("general", "ftp_upload_url")
except:
self._print(_("No URL defined in config file."))
return

from urlparse import urlparse
url = urlparse(upload_url)

if url[0] != "ftp":
self._print(_("Cannot upload to specified URL."))
return

# extract username and password from URL, if present
if url[1].find("@") > 0:
username, host = url[1].split("@", 1)
if username.find(":") > 0:
username, passwd = username.split(":", 1)
else:
passwd = None
else:
username, passwd, host = None, None, url[1]

# extract port, if present
if host.find(":") > 0:
host, port = host.split(":", 1)
port = int(port)
else:
port = 21

path = url[2]

try:
from ftplib import FTP
upload_name = os.path.basename(final_filename)

ftp = FTP()
ftp.connect(host, port)
if username and passwd:
ftp.login(username, passwd)
else:
ftp.login()
ftp.cwd(path)
ftp.set_pasv(True)
ftp.storbinary('STOR %s' % upload_name, fp)
ftp.quit()
except Exception as e:
self._print(_("There was a problem uploading your report to Red Hat support. " + str(e)))
else:
self._print(_("Your report was successfully uploaded to %s with name:" % (upload_url,)))
self._print(" " + upload_name)
self._print()
self._print(_("Please communicate this name to your support representative."))
self._print()

fp.close()

def _print(self, msg=None):
"""A wrapper around print that only prints if we are not running in
Expand Down
24 changes: 1 addition & 23 deletions sos/sosreport.py
Expand Up @@ -210,7 +210,6 @@ class SoSOptions(object):
_onlyplugins = []
_plugopts = []
_usealloptions = False
_upload = False
_batch = False
_build = False
_verbosity = 0
Expand Down Expand Up @@ -309,19 +308,6 @@ def usealloptions(self, value):
raise TypeError("SoSOptions.usealloptions expects a boolean")
self._usealloptions = value

@property
def upload(self):
if self._options != None:
return self._options.upload
return self._upload

@upload.setter
def upload(self, value):
self._check_options_initialized()
if not isinstance(value, bool):
raise TypeError("SoSOptions.upload expects a boolean")
self._upload = value

@property
def batch(self):
if self._options != None:
Expand Down Expand Up @@ -492,9 +478,6 @@ def _parse_args(self, args):
parser.add_option("-a", "--alloptions", action="store_true",
dest="usealloptions", default=False,
help="enable all options for loaded plugins")
parser.add_option("-u", "--upload", action="store",
dest="upload", default=False,
help="upload the report to an ftp server")
parser.add_option("--batch", action="store_true",
dest="batch", default=False,
help="batch mode - do not prompt interactively")
Expand Down Expand Up @@ -1138,12 +1121,7 @@ def final_work(self):
else:
final_filename = self.archive.get_archive_path()

# automated submission will go here
if not self.opts.upload:
self.policy.display_results(final_filename, build = self.opts.build)
else:
self.policy.upload_results(final_filename)

self.policy.display_results(final_filename, build = self.opts.build)
self.tempfile_util.clean()

return True
Expand Down

0 comments on commit d523cfb

Please sign in to comment.