Bug 960984 - spacecmd errors when passed a system id (at least system_addchildchannels)
spacecmd errors when passed a system id (at least system_addchildchannels)
Status: CLOSED CURRENTRELEASE
Product: Spacewalk
Classification: Community
Component: Clients (Show other bugs)
1.9
All Linux
unspecified Severity medium
: ---
: ---
Assigned To: Milan Zazrivec
Red Hat Satellite QA List
:
Depends On:
Blocks: space21
  Show dependency treegraph
 
Reported: 2013-05-08 09:01 EDT by Mark Chappell
Modified: 2014-03-04 08:08 EST (History)
1 user (show)

See Also:
Fixed In Version: spacecmd-2.1.18-1
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-03-04 08:06:35 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Mark Chappell 2013-05-08 09:01:19 EDT
Description of problem:

We re-provision hosts using cobbler/kickstart, in doing so we can end up with systems with duplicate names.

Because expand_systems (spacecmd/src/lib/misc.py) generally expands searches to system names rather than IDs even when we use "search:id:<ID>" we keep running into:

"""
WARNING: Duplicate system profile names found
WARNING: You can delete duplicates with 'system_delete'
WARNING: <REDACTED>.redhat.com = 1000027323, 1000012783
WARNING: Duplicate system profile names found
WARNING: You can delete duplicates with 'system_delete'
WARNING: <REDACTED>.redhat.com = 1000027323, 1000012783
"""

However, if we explicitly pass a system ID, then manipulate_child_channels (spacecmd/src/lib/system.py) errors because it sees an integer rather than a string when trying to print the list of systems that will be updated...:

  97     print '\n'.join(sorted(systems))

"""
ERROR: sequence item 0: expected string, int found
Traceback (most recent call last):
  File "/usr/bin/spacecmd", line 127, in ?
    shell.onecmd(shell.precmd(' '.join(args)))
  File "/usr/lib64/python2.4/cmd.py", line 219, in onecmd
    return func(arg)
  File "/usr/lib/python2.4/site-packages/spacecmd/system.py", line 1804, in do_system_addchildchannels
    self.manipulate_child_channels(args)
  File "/usr/lib/python2.4/site-packages/spacecmd/system.py", line 96, in manipulate_child_channels
    print '\n'.join(sorted(systems))
TypeError: sequence item 0: expected string, int found
"""

IMHO there are two bugs here
1) expand_systems is passing back a non-unique field (name) rather than a unique field (id) - not sure if you're likely to do anything about this one, happy to generate a second bug.
2) the use of a simple join(sorted(systems)) when an integer is perfectly valid - hopefully this one might get fixed...

Version-Release number of selected component (if applicable):

spacecmd-1.9.4-1.el6.noarch

How reproducible:

Every #?!@ing time

Steps to Reproduce:
1. re-add a host (eg re run rhnreg_ks) so that you have two hosts with the same name
2. run "spacecmd system_addchildchannels <id> <some child channel>"
  
Actual results:

EXCEPTION

Expected results:

childchannel added

Additional info:

Same lazy join is found in various places
src/lib/softwarechannel.py:            print '\n'.join(sorted(systems))
src/lib/report.py:        print '\n'.join(sorted(systems))
src/lib/system.py:    print '\n'.join(sorted(systems))
src/lib/system.py:    print '\n'.join(sorted(systems))
src/lib/system.py:    print '\n'.join(sorted(systems))
src/lib/system.py:    print '\n'.join(sorted(systems))
src/lib/group.py:    print '\n'.join(sorted(systems))
src/lib/group.py:            print '\n'.join(sorted(systems))
src/lib/group.py:            print '\n'.join(sorted(systems))
Comment 1 Milan Zazrivec 2013-12-13 10:03:17 EST
Problem 1 -- cannot reproduce with spacecmd-2.1.17-1

Problem 2 fixed in spacewalk.git master: 65efaf38345ccb2dd51b122fb1653c071973eccf
Comment 2 Matej Kollar 2014-01-17 07:15:28 EST
Switching MODIFIED Spacewalk bugs to ON_QA before 2.1 release.
Comment 3 Matej Kollar 2014-03-04 08:06:35 EST
Spacewalk 2.1 has been released.
https://fedorahosted.org/spacewalk/wiki/ReleaseNotes21
Comment 4 Matej Kollar 2014-03-04 08:08:33 EST
Spacewalk 2.1 has been released.
https://fedorahosted.org/spacewalk/wiki/ReleaseNotes21

Note You need to log in before you can comment on or make changes to this bug.