[Spacewalk-list] ERROR: 'list' object has no attribute 'keys'

Mertens, Bram mertensb at mazdaeur.com
Tue Jul 9 14:28:31 UTC 2013


>


Mazda Motor Logistics Europe NV, Blaasveldstraat 162, B-2830 Willebroek
VAT BE 0406.024.281, RPR Mechelen, ING  310-0092504-52, IBAN : BE64 3100 0925 0452, SWIFT : BBRUBEBB


This e-mail is intended to be used by the recipient(s) only. The information contained in this e-mail and the attached files, if any, is confidential and may be protected by intellectual property or other rights. If you receive this e-mail by mistake, please notify the sender, remove this e-mail from your system and delete all copies of it. You may not, directly or indirectly, use (any part of) this e-mail if you are not the intended recipient.
The e-mails and the attached files have been checked for viruses according to standard procedures, but this does not guarantee that the e-mail and/or attached files are free of viruses. Mazda does not accept any liability in this respect. Always scan attachments before opening them.
This e-mail does not constitute a commitment by Mazda to enter into or assume any obligation, contractual, financial or otherwise, nor a warranty or representation, except when expressly otherwise agreed in a separate written agreement between the recipient and Mazda.-----Original Message-----
> From: spacewalk-list-bounces at redhat.com [mailto:spacewalk-list-
> bounces at redhat.com] On Behalf Of Mertens, Bram
> Sent: vrijdag 5 juli 2013 11:51
> To: spacewalk-list at redhat.com
> Subject: [Spacewalk-list] ERROR: 'list' object has no attribute 'keys'
>
> Hi,
>
> I've recently started using spacecmd and I like it a lot already.
>
> There are a couple of things I'm unable to do still for which I've had to revert
> to the webUI but perhaps I haven't found all of the available documentation
> yet.  If there are any docs available outside the fedorahosted trac
> (https://fedorahosted.org/spacewalk/wiki ) please point me in the right
> direction.  (google isn't much help as it directs me to a lot of air force stuff
> most of the time :) )
>
> Right now I want to change the basechannel for a number of systems I've
> selected in SSM.
> The command fails with the error message in the subject.
> spacecmd {SSM:22}> ssm_intersect channel:rhel-x86_64-server-6
> spacecmd {SSM:5}> ssm_list
> check_kickstart_60
> defrldas001.mle.mazdaeur.com
> defrldas002.mme.mazdaeur.com
> localhost.localdomain
> testsrv2
> spacecmd {SSM:5}> help system_setbasechannel
> system_setbasechannel: Set a system's base software channel
> usage: system_setbasechannel <SYSTEMS> CHANNEL
>
> <SYSTEMS> can be any of the following:
> name
> ssm (see 'help ssm')
> search:QUERY (see 'help system_search')
> group:GROUP
> channel:CHANNEL
>
> spacecmd {SSM:5}> system_setbasechannel ssm dev-rhel-x86_64-server-6
> ERROR: 'list' object has no attribute 'keys'
> spacecmd {SSM:5}>
>
> This is version spacecmd-1.2.2-1.el5
>
> Am I doing something wrong here? Or is spacecmd?

It looks like the issue is in the ssm_intersect.
In debug mode:
spacecmd {SSM:22}> ssm_clear
spacecmd {SSM:0}> ssm_add group:DEV
DEBUG: Added defrldas002.mme.mazdaeur.com
...
DEBUG: Systems Selected: 22
spacecmd {SSM:22}> ssm_intersect group:HPManaged
DEBUG: lemansdbdvlsrv.mle.mazdaeur.com is in both groups: leaving in SSM
DEBUG: defrldas001.mle.mazdaeur.com is in both groups: leaving in SSM
DEBUG: Systems Selected: 2
spacecmd {SSM:2}> ssm_list
defrldas001.mle.mazdaeur.com
lemansdbdvlsrv.mle.mazdaeur.com
DEBUG: Systems Selected: 2
spacecmd {SSM:2}> group_addsystems HP-DEV ssm
ERROR: 'list' object has no attribute 'keys'
Traceback (most recent call last):
  File "/usr/bin/spacecmd", line 153, in ?
    shell.cmdloop()
  File "/usr/lib64/python2.4/cmd.py", line 142, in cmdloop
    stop = self.onecmd(line)
  File "/usr/lib64/python2.4/cmd.py", line 219, in onecmd
    return func(arg)
  File "/usr/lib/python2.4/site-packages/spacecmd/group.py", line 52, in do_group_addsystems
    systems = self.ssm.keys()
AttributeError: 'list' object has no attribute 'keys'
spacecmd {SSM:2}> ssm_clear
spacecmd {SSM:0}> ssm_add lemansdbdvlsrv.mle.mazdaeur.com
DEBUG: Added lemansdbdvlsrv.mle.mazdaeur.com
DEBUG: Systems Selected: 1
spacecmd {SSM:1}> ssm_add defrldas001.mle.mazdaeur.com
DEBUG: Added defrldas001.mle.mazdaeur.com
DEBUG: Systems Selected: 2
spacecmd {SSM:2}> group_addsystems HP-DEV ssm
spacecmd {SSM:2}>

I'm no expert but I believe the problem is the following:
In shell.py the ssm is configured as a dict:
 52     def __init__(self, options):
 53         self.session = ''
 54         self.username = ''
 55         self.server = ''
 56         self.ssm = {}

But in ssm.py the do_ssm_intersect returns a list:
98 def do_ssm_intersect(self, args):
 99     (args, options) = parse_arguments(args)
...
113     tmp_ssm = []
114     for system in systems:
115         if system in self.ssm:
116             logging.debug('%s is in both groups: leaving in SSM' % system)
117             tmp_ssm.append(system)
118
119     # set self.ssm to tmp_ssm, which now holds the intersection
120     self.ssm = tmp_ssm

At this point self.ssm is a list not a dict causing the self.ssm.keys() to fail.

I'll open a support case.

Regards

Bram




More information about the Spacewalk-list mailing list