[PATCH 0/2] Add default network card name existence check

Some default name of network cards is set as "eth0", "eth1" or "em1". But when some system doesn't contain such a name, the testcase would fail. Hence these patches added check of default network card and if it doesn't exists in the network info list, the default name would be changed into the first one except "lo". The second patch is updated with default network card check in libvirt-cim. Xu Wang (2): cimtest: Add default network existence check to 28_definesystem_with_vsi_profile.py cimtest: Add default network existence check to 06_parent_net_pool.py .../libvirt-cim/cimtest/RASD/06_parent_net_pool.py | 16 +++++++++++++--- .../28_definesystem_with_vsi_profile.py | 9 +++++++++ 2 files changed, 22 insertions(+), 3 deletions(-)

From: Xu Wang <cngesaint@gmail.com> The default network card name is 'eth0' or 'em1'. But if the network card name doesn't contain those values, error would occur. So this patch will check if the default network card name exists in the network card name list. If not, the network card name would changed into the first one in the network card name list except lo. Signed-off-by: Xu Wang <gesaint@linux.vnet.ibm.com> --- .../28_definesystem_with_vsi_profile.py | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py index 2b108f9..a901ae7 100644 --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py @@ -33,6 +33,7 @@ # import sys +import os from CimTest.Globals import logger from CimTest.ReturnCodes import FAIL, PASS, SKIP, XFAIL_RC, XFAIL from VirtLib import utils @@ -188,6 +189,14 @@ def main(): if rc == 0: vsi_defaults['SourceDevice'] = "em1" + # 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. + net_info = os.popen('ip addr').read() + if net_info.find(vsi_defaults['SourceDevice']) == -1: + vsi_defaults['SourceDevice'] = net_info.split(': ')[3] + nrasd_cn = get_typed_class(virt, 'NetResourceAllocationSettingData') status = FAIL cxml = None -- 1.7.1

On 07/31/2013 10:08 PM, Xu Wang wrote:
From: Xu Wang <cngesaint@gmail.com>
The default network card name is 'eth0' or 'em1'. But if the network card name doesn't contain those values, error would occur. So this patch will check if the default network card name exists in the network card name list. If not, the network card name would changed into the first one in the network card name list except lo.
Signed-off-by: Xu Wang <gesaint@linux.vnet.ibm.com>
Although the test fails in general for me based on my system configuration, I did verify that by using either "eth1" or "em1" as the initial value, that the changes here work, so ACK John
--- .../28_definesystem_with_vsi_profile.py | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py index 2b108f9..a901ae7 100644 --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py @@ -33,6 +33,7 @@ #
import sys +import os from CimTest.Globals import logger from CimTest.ReturnCodes import FAIL, PASS, SKIP, XFAIL_RC, XFAIL from VirtLib import utils @@ -188,6 +189,14 @@ def main(): if rc == 0: vsi_defaults['SourceDevice'] = "em1"
+ # 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. + net_info = os.popen('ip addr').read() + if net_info.find(vsi_defaults['SourceDevice']) == -1: + vsi_defaults['SourceDevice'] = net_info.split(': ')[3] + nrasd_cn = get_typed_class(virt, 'NetResourceAllocationSettingData') status = FAIL cxml = None

From: Xu Wang <cngesaint@gmail.com> The default network card name is 'eth0' or 'em1'. But if the network card name doesn't contain those values, error would occur. So this patch will check if the default network card name exists in the network card name list. If not, the network card name would changed into the first one in the network card name list except lo. Signed-off-by: Xu Wang <gesaint@linux.vnet.ibm.com> --- .../libvirt-cim/cimtest/RASD/06_parent_net_pool.py | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-) diff --git a/suites/libvirt-cim/cimtest/RASD/06_parent_net_pool.py b/suites/libvirt-cim/cimtest/RASD/06_parent_net_pool.py index 2c1f285..5f330e1 100644 --- a/suites/libvirt-cim/cimtest/RASD/06_parent_net_pool.py +++ b/suites/libvirt-cim/cimtest/RASD/06_parent_net_pool.py @@ -39,7 +39,7 @@ # -Netmask="255.255.255.0" # -IPRangeStart="192.168.122.2" # -IPRangeEnd="192.168.122.254" -# -ForwardDevice= [ verified for 'None' and "eth0" ] +# -ForwardDevice= [ verified for 'None' and network card name (default is 'eth0') ] # -ForwardMode=0 [ verified for 1,2 as well ] # # @@ -47,6 +47,7 @@ # Date : 18-05-2009 import sys +import os from sets import Set from CimTest.Globals import logger from XenKvmLib.const import do_main @@ -67,6 +68,15 @@ def main(): options = main.options virt = options.virt server = options.ip + net_dev = 'eth0' + + # The default device name may not named 'eth0', 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. + net_info = os.popen('ip addr').read() + if net_info.find(net_dev) == -1: + net_dev = net_info.split(': ')[3] status, netpool_rasd = get_pool_rasds(server, virt, filter_default=False) if status != PASS: @@ -80,8 +90,8 @@ def main(): 'IPRangeStart' : "192.168.122.2", 'IPRangeEnd' : "192.168.122.254" } - exp_mode_device = [('None', 0L), ('None', 1L), ('eth0', 1L), - ('None', 2L), ('eth0', 2L)] + exp_mode_device = [('None', 0L), ('None', 1L), (net_dev, 1L), + ('None', 2L), (net_dev, 2L)] for inst_type in inst_list: logger.info("Verifying '%s' records", inst_type) -- 1.7.1

On 07/31/2013 10:08 PM, Xu Wang wrote:
From: Xu Wang <cngesaint@gmail.com>
The default network card name is 'eth0' or 'em1'. But if the network card name doesn't contain those values, error would occur. So this patch will check if the default network card name exists in the network card name list. If not, the network card name would changed into the first one in the network card name list except lo.
Signed-off-by: Xu Wang <gesaint@linux.vnet.ibm.com> --- .../libvirt-cim/cimtest/RASD/06_parent_net_pool.py | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/suites/libvirt-cim/cimtest/RASD/06_parent_net_pool.py b/suites/libvirt-cim/cimtest/RASD/06_parent_net_pool.py index 2c1f285..5f330e1 100644 --- a/suites/libvirt-cim/cimtest/RASD/06_parent_net_pool.py +++ b/suites/libvirt-cim/cimtest/RASD/06_parent_net_pool.py @@ -39,7 +39,7 @@ # -Netmask="255.255.255.0" # -IPRangeStart="192.168.122.2" # -IPRangeEnd="192.168.122.254" -# -ForwardDevice= [ verified for 'None' and "eth0" ] +# -ForwardDevice= [ verified for 'None' and network card name (default is 'eth0') ] # -ForwardMode=0 [ verified for 1,2 as well ] # # @@ -47,6 +47,7 @@ # Date : 18-05-2009
import sys +import os from sets import Set from CimTest.Globals import logger from XenKvmLib.const import do_main @@ -67,6 +68,15 @@ def main(): options = main.options virt = options.virt server = options.ip + net_dev = 'eth0' + + # The default device name may not named 'eth0', 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. + net_info = os.popen('ip addr').read() + if net_info.find(net_dev) == -1: + net_dev = net_info.split(': ')[3]
status, netpool_rasd = get_pool_rasds(server, virt, filter_default=False) if status != PASS: @@ -80,8 +90,8 @@ def main(): 'IPRangeStart' : "192.168.122.2", 'IPRangeEnd' : "192.168.122.254" } - exp_mode_device = [('None', 0L), ('None', 1L), ('eth0', 1L), - ('None', 2L), ('eth0', 2L)] + exp_mode_device = [('None', 0L), ('None', 1L), (net_dev, 1L), + ('None', 2L), (net_dev, 2L)]
'git am' gives a warning about extraneous whitespace... Thus... s/1L), /1L),/ Beyond that - this test fails for me: RASD - 06_parent_net_pool.py: FAIL ERROR - Exception details: Mismatching Mode and device values, Got [('None', 0L), ('None', 1L), ('em1', 1L), ('None', 2L), ('em1', 2L)], Expected [('None', 0L), ('None', 1L), ('eth0', 1L), ('None', 2L), ('eth0', 2L)] -------------------------------------------------------------------- It doesn't matter what I initialize 'net_dev' to (em1, foobar, etc), the filling of 'n_rec' returns eth0. I wasn't able to directly run the wbemcli command in the comments to the code, but it seems from reading the libvirt-cim code: "src/Virt_SettingsDefineCapabilities.c" set_net_pool_props(): if (i == 1) { CMSetProperty(inst, "ForwardDevice", (CMPIValue *)"eth0", CMPI_chars); } It seems perhaps we need to fix that first! John
for inst_type in inst_list: logger.info("Verifying '%s' records", inst_type)
participants (2)
-
John Ferlan
-
Xu Wang