[Libvirt-cim] [PATCH] [TEST] #3 Fix ElementCapabilities/03_forward_errs.py with provider's updated err message

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Tue Mar 10 20:08:36 UTC 2009


>> > >  > Remove the "+" sign here. Only slash is enough.
>> > Also, instead of calling try_assoc twice you can do the following:
>> >
>> > if curr_cim_rev >= libvirt_ec_changes:
>> >         exp_desc = "Referenced domain `wrong' does not exist:"  \
>> >                      " Domain not found"
>> >
>> > I tried to do this in the first patch, but it reports error as follows:
>>
>>   ERROR   - UnboundLocalError : local variable 'exp_desc' referenced 
>> before assignment
>>   Traceback (most recent call last):
>>   File "./lib/XenKvmLib/const.py", line 141, in do_try
>>   File "03_forward_errs.py", line 80, in main
>>     rc = try_assoc(instanceref, hs, exp_rc, exp_desc, options)
>> UnboundLocalError: local variable 'exp_desc' referenced before assignment
>> ERROR   - None
> The error is coming from line no 80 and not from the control stmt added.
> Let me check this.
>>  
>>   So I define a new variable of cs_exp_desc to cover this and call 
>> try_assco twice.
>>

This is because exp_desc is defined outside of main().  main() doesn't 
own the exp_desc variable, so it's unable to modify it.

Instead of defining exp_desc and exp_rc at the top of the file, define 
both in main().

Or, you can do something like the following:

cs_exp_desc = exp_desc

curr_cim_rev, changeset = get_provider_version(options.virt, options.ip)
if curr_cim_rev >= libvirt_ec_changes:
     cs_exp_desc = "Referenced domain `wrong' does not exist:" + \
                   " Domain not found"

try_assoc(instance_cs, cs, exp_rc, cs_exp_desc, options)

Whichever is fine.

-- 
Kaitlin Rupert
IBM Linux Technology Center
kaitlin at linux.vnet.ibm.com




More information about the Libvirt-cim mailing list