Kaitlin Rupert wrote:
>>
>> + if options.virt == "Xen" or options.virt == "XenFV":
>> + libvirt_version = virsh_version(options.ip, options.virt)
>> + if libvirt_version <= "0.3.3":
>> + expected_values['empty']['network'] = "no
network with
>> matching name"
>> + expected_values['invalid']['network'] = "no
network
>> with matching name"
>> +
>> + inv_br_str = "POST operation failed: (xend.err 'Device
>> 0 (vif) " + \
>> + "could not be connected. Could not find
>> bridge device " + \
>> + "invalid')"
>> +
>> + expected_values['invalid']['bridge'] = inv_br_str
>> +
>> + else:
>> + expected_values['empty']['network'] = "Network
not found"
>> + expected_values['invalid']['network'] =
"Network not
>> found"
>> + + inv_br_str = "POST operation failed:
>> xend_post: error from xen " + \
>> + "daemon: (xend.err 'Device 0 (vif) could
>> not be " + \
>> + "connected. Could not find bridge device
>> invalid')"
>> + expected_values['invalid']['bridge'] = inv_br_str
>>
> We can use a common variable to assign these error messages get the
> assignment to the expected_values fields before coming out of the
>
> inv_br_str check.
>
Not sure what you mean here...
But any suggestions appreciated, because what I have here isn't very
pretty. =)
Sorry for not being clear.
What I meant is the fields expected_values['empty']['network'] and
expected_values['invalid']['network'] have similar values that are
assigned so we can use one var inside the if conditions to assign
appropriate value.
Also, the value for the field expected_values['invalid']['bridge'] is
stored in inv_br_str .
We can use the variables in which the values are assigned after the if
else and assign it for once instead of repeating the same separately in
the if and else conditions.
For ex:
if options.virt == "Xen" or options.virt == "XenFV":
libvirt_version = virsh_version(options.ip, options.virt)
if libvirt_version <= "0.3.3":
net_invalid_empty = "no network with matching name"
inv_br_str = "POST operation failed: (xend.err 'Device 0
(vif) " + \
"could not be connected. Could not find bridge
device " + \
"invalid')"
else:
net_invalid_empty = "Network not found"
inv_br_str = "POST operation failed: xend_post: error from
xen " + \
"daemon: (xend.err 'Device 0 (vif) could not be
" + \
"connected. Could not find bridge device
invalid')"
expected_values['empty']['network'] =
expected_values['invalid']['network'] = net_invalid_empty
expected_values['invalid']['bridge'] = inv_br_str
--
Thanks and Regards,
Deepti B. Kalakeri
IBM Linux Technology Center
deeptik(a)linux.vnet.ibm.com