[Libvirt-cim] [PATCH V2 1/3] cimtest: Add default network card name existence check to 27_definesystem_macvtap_dev.py

John Ferlan jferlan at redhat.com
Thu Aug 8 19:38:52 UTC 2013


On 08/07/2013 04:37 AM, Xu Wang wrote:
> Default network card name was set as 'eth1' or 'em1'. But when os has no network card named like that, FAIL
> would occured. This patch added check if default name exists in the network card list and if not, change
> the default value into the 1st one in the list.
> 

I believe you neglected git pull --refresh before sending this patch as
it doesn't apply to the top of the .git tree since DV pushed your
previous patch...


> Signed-off-by: Xu Wang <gesaint at linux.vnet.ibm.com>
> ---
>  .../27_definesystem_macvtap_dev.py                 |   16 ++++++++++++++++
>  1 files changed, 16 insertions(+), 0 deletions(-)
> 
> diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/27_definesystem_macvtap_dev.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/27_definesystem_macvtap_dev.py
> index 36bf52f..bc8c100 100644
> --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/27_definesystem_macvtap_dev.py
> +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/27_definesystem_macvtap_dev.py
> @@ -132,6 +132,22 @@ def main():
>      else:
>          source_dev = "eth1"
>  
> +    # The default device name may not named 'eth1' or 'em1' so this case would
> +    # return FAIL. The following code will check if default device exists in
> +    # the network card list and if not, source_dev will be changed into the 1st
> +    # network card in the list.
> +    f = open("/proc/net/dev")
> +    lines = f.readlines()
> +    f.close()
> +    if str(lines).find(source_dev) <> -1:
> +        """
> +        source_dev exists in the network info list and keep it.
> +        """
> +    else:
> +        line = lines[2]

why pick 2?  other than 1 being "lo"?  what makes us sure that this is
correct and usable?

> +        con = line.split(":")
> +        source_dev = con[0].strip(" ")
> +

There should be a more common way to do this rather than cut-n-paste
into 3 modules...

John
>      guest_defined = False
>  
>      try:
> 




More information about the Libvirt-cim mailing list