Bug 822637

Summary: rhua-manager cli needs to catch invalid data
Product: Red Hat Update Infrastructure for Cloud Providers Reporter: wes hayutin <whayutin>
Component: RHUAAssignee: wes hayutin <whayutin>
Status: CLOSED ERRATA QA Contact: Martin Kočí <mkoci>
Severity: unspecified Docs Contact:
Priority: high    
Version: 2.1CC: jslagle, juwu, kbidarka, mkoci, sghai, tsanders
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
For #rhui-manager repo info, and #rhui-manager packages list, when invalid data is passed, ugly traceback is returned. Patches have been applied to render.py and packages.py so that when invalid data is passed, it only returns repo_id/repository not found.
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-08-24 11:54:36 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
patch to catch invalid repos provided via rhua-manager cli
none
patch for a cleaner message to users when an invalid repo is passed none

Description wes hayutin 2012-05-17 16:49:52 UTC
Description of problem:

[whayutin@minidoe tools]$ PYTHONPATH=src/ bin/rhui-manager --config dev/rhui-tools.conf repo info --repo_id 3

rhui-manager throws an ugly exception if bogus data is passed via the command line

Traceback (most recent call last):
  File "bin/rhui-manager", line 16, in <module>
    rhui.tools.launcher.main()
  File "/home/whayutin/workspace/cloude/rhui-2.0/tools/src/rhui/tools/launcher.py", line 341, in main
    cli.run(args)
  File "/home/whayutin/workspace/cloude/rhui-2.0/tools/src/rhui/common/cli.py", line 277, in run
    command_or_section.execute(remaining_args)
  File "/home/whayutin/workspace/cloude/rhui-2.0/tools/src/rhui/common/cli.py", line 118, in execute
    self.method(**arg_dict)
  File "/home/whayutin/workspace/cloude/rhui-2.0/tools/src/rhui/tools/commands/repo.py", line 70, in info
    render.display_repo_details(self.prompt, repo)
  File "/home/whayutin/workspace/cloude/rhui-2.0/tools/src/rhui/tools/render.py", line 131, in display_repo_details
    if GROUP_RED_HAT in repo['groupid']:
TypeError: 'NoneType' object is not subscriptable

Comment 1 wes hayutin 2012-05-17 17:27:17 UTC
Created attachment 585279 [details]
patch to catch invalid repos provided via rhua-manager cli

Comment 2 wes hayutin 2012-05-17 18:07:32 UTC
Created attachment 585293 [details]
patch for a cleaner message to users when an invalid repo is passed

Comment 3 wes hayutin 2012-05-18 18:19:04 UTC
[whayutin@minidoe tools]$ PYTHONPATH=src/ bin/rhui-manager --config dev/rhui-tools.conf --debug repo info --repo_id 3
No repositories found


This appears to be working w/o changes
cloude commit 189483f24a6e6ddf6dabcac65b2f561ad550b11e
pulp commit e05ced383504133543ac7b6114b45c98699b6e61

moving to on_qa

Comment 4 wes hayutin 2012-05-18 18:28:12 UTC
cloude commit ede48cd639a19fef3666380eecbf46c7e95a80fd

fixed rhui-manager packages list --repo_id

Comment 5 Martin Kočí 2012-08-01 15:09:42 UTC
It seems fixes are not merged with the latest version: 
/root/RHEL-6.3-RHUI-2.1-20120731.0-Server-x86_64-DVD1.iso on /tmp/mnt type iso9660 (rw,loop=/dev/loop0)

[root@ip-10-85-5-60 usr]# PYTHONPATH=src/ bin/rhui-manager --config /etc/rhui/rhui-tools.conf repo info --repo_id 3
Traceback (most recent call last):
  File "bin/rhui-manager", line 16, in <module>
    rhui.tools.launcher.main()
  File "/usr/lib/python2.6/site-packages/rhui/tools/launcher.py", line 348, in main
    cli.run(args)
  File "/usr/lib/python2.6/site-packages/rhui/common/cli.py", line 272, in run
    command_or_section.execute(remaining_args)
  File "/usr/lib/python2.6/site-packages/rhui/common/cli.py", line 113, in execute
    self.method(**arg_dict)
  File "/usr/lib/python2.6/site-packages/rhui/tools/commands/repo.py", line 71, in info
    render.display_repo_details(self.prompt, repo)
  File "/usr/lib/python2.6/site-packages/rhui/tools/render.py", line 135, in display_repo_details
    if GROUP_RED_HAT in repo['groupid']:
TypeError: 'NoneType' object is unsubscriptable

Moving bug to ON_DEV

Comment 6 wes hayutin 2012-08-01 15:56:47 UTC
looks fine in the latest build..

here is a sample plan..


[root@ip-10-70-90-96 ~]# rhui-manager repo list --help
Usage: rhui-manager [options]

Options:
  -h, --help  show this help message and exit
list: lists all repositories in the RHUI
[root@ip-10-70-90-96 ~]# rhui-manager repo info
info: displays information on an individual repo
    --repo_id - identifies the repository to display (required)

The following options are required but were not specified:
    --repo_id
[root@ip-10-70-90-96 ~]# rhui-manager repo info --repo_id rhel-server-5-5Server-x86_64
Name:                Red Hat Enterprise Linux Server 5 (RPMs) (5Server-x86_64)
Type:                Red Hat
Relative Path:       content/dist/rhel/rhui/server/5/5Server/x86_64/os
Package Count:       13912
Last Sync:           08-01-2012 06:17
Next Sync:           08-01-2012 11:37
[root@ip-10-70-90-96 ~]# rhui-manager repo info --repo_id
Usage: rhui-manager [options]

info: displays information on an individual repo
    --repo_id - identifies the repository to display (required)
[root@ip-10-70-90-96 ~]#

Comment 7 wes hayutin 2012-08-01 17:00:30 UTC
b3895b0827e5d41d03ee0dcf97e1f50dade492c6
bf882b877d575825307dd21879319e22df045925

k.. this should be fixed for any use case in "repo" and "packages"

good catch

Comment 8 Martin Kočí 2012-08-02 11:52:29 UTC
VERIFIED against 
/root/RHEL-6.3-RHUI-2.1-20120801.0-Server-x86_64-DVD1.iso

[root@ip-10-46-39-253 ~]# rhui-manager repo info --repo_id doesntexist
repository doesntexist was not found
[root@ip-10-46-39-253 ~]# rhui-manager packages list --repo_id doesntexist
repo_id not found

Moving bug to VERIFIED

Comment 9 Julie 2012-08-15 20:09:39 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
For #rhui-manager repo info, and #rhui-manager packages list, when invalid data is passed, ugly traceback is returned. Patches have been applied to render.py and packages.py so that when invalid data is passed, it only returns repo_id/repository not found.

Comment 11 errata-xmlrpc 2012-08-24 11:54:36 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHEA-2012-1205.html