libvirt-cim-bounces(a)redhat.com wrote on 2009-03-11 04:08:36:
>> > > > 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.
I submit a patch like the second option before, and deepti
suggested that it's not a good idea to call the try_assoc() twice.
I will submit a new patch with define the exp_rc and exp_desc inside
of main().
Thanks!
--
Kaitlin Rupert
IBM Linux Technology Center
kaitlin(a)linux.vnet.ibm.com
_______________________________________________
Libvirt-cim mailing list
Libvirt-cim(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvirt-cim