Bug 960984 - spacecmd errors when passed a system id (at least system_addchildchannels)
Summary: spacecmd errors when passed a system id (at least system_addchildchannels)
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Spacewalk
Classification: Community
Component: Clients
Version: 1.9
Hardware: All
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Milan Zázrivec
QA Contact: Red Hat Satellite QA List
URL:
Whiteboard:
Depends On:
Blocks: space21
TreeView+ depends on / blocked
 
Reported: 2013-05-08 13:01 UTC by Mark Chappell
Modified: 2014-03-04 13:08 UTC (History)
1 user (show)

Fixed In Version: spacecmd-2.1.18-1
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-03-04 13:06:35 UTC
Embargoed:


Attachments (Terms of Use)

Description Mark Chappell 2013-05-08 13:01:19 UTC
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 Zázrivec 2013-12-13 15:03:17 UTC
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 12:15:28 UTC
Switching MODIFIED Spacewalk bugs to ON_QA before 2.1 release.

Comment 3 Matej Kollar 2014-03-04 13:06:35 UTC
Spacewalk 2.1 has been released.
https://fedorahosted.org/spacewalk/wiki/ReleaseNotes21

Comment 4 Matej Kollar 2014-03-04 13:08:33 UTC
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.